Workforce Management API - Update Schedules

Hello,

I was wondering if the API at https://developer.genesys.cloud/api/rest/v2/workforcemanagement/upload-update_schedule is still up to date?

I am trying to make a request to the API and I am always getting error 400 Bad Request.

The URL for the request:
https://apps.mypurecloud.com/uploads/v4/services/workforcemanagement/businessunits/e77d0991-c424-4fec-aeca-09217fcda52d/weeks/2021-10-25/schedules/81fac0ff-ec4a-4a63-a911-cb07601c7c1a

I have a business unit with id : e77d0991-c424-4fec-aeca-09217fcda52d
I have a schedule starting 2021-10-25 with id: 81fac0ff-ec4a-4a63-a911-cb07601c7c1a
I use OAuth for authentication on Postman, tested and working for requests on https://developer.genesys.cloud/api/rest/v2/workforcemanagement/.

The body of my request:


{
   "metadata":{
      "version":1
   },
   "agentSchedules":[
      {
         "userId":"[MY USER ID - HIDDEN FOR FORUM]",
         "shifts":[
            {
               "activities":[
                  {
                     "activityCodeId":"0",
                     "startDate":"2021-10-25T07:20:00.000Z",
                     "lengthMinutes":120,
                     "description":"Sample description",
                     "paid":true
                  }
               ],
               "manuallyEdited":true
            }
         ],
         "fullDayTimeOffMarkers":[          
         ],
         "metadata":{
            "version":1
         }
      }
   ]
}

Thanks,
Leandre

Do you have a correlationId from the response header for the bad request?

Hello,

The ININ-Correlation-Id is : 6298fd11-f891-4bb5-96f7-91ebfef4b1b9

Thank you,
Leandre

The error I'm seeing in the logs is "Refusing to process non-multipart upload."

Are you setting the content type header with "multipart/..." on your request?

Can you post an example request, complete with headers (be sure to redact any cookies or auth tokens or other sensitive data)?

Hello,

Here is the header:

The request URL is a Post request. The URL is the one I sent in my initial message.
The request body is the same as the one I sent in my initial message.
The OAuth token was granted as client credentials.

I am not setting the content type to multipart in the request header.

Thanks,
Leandre

In your screen shot, you have Content-Type set to application/json. It needs to be something prefixed with multipart/. I looked at what our official UI sends and it uses ContentType:multipart/form-data. If you change that header it should resolve your issue..

Also, in the coming months we have an updated/simplified process coming out for importing/updating schedules that should make this a lot easier. The current method of updating schedules via /uploads will continue to work but will be deprecated at that time.

Hello,

Sorry for the trouble, it does work. I guess I went over the documentation too fast..

Thanks a lot,
Leandre

1 Like

All good, glad you got it worked out!

Hello,

Just a quick question (I can create another topic if needed).

I might not fully understand the concept of updating a schedule. In my request .json file, I have the following:


{
   "metadata":{
      "version":4
   },
   "published": true,
   "agentSchedules":[
      {
         "userId":"b9d50055-8ac0-477e-bc8e-fe16371ee630",
         "shifts":[
            {
               "activities":[
				  {
                     "activityCodeId":"0",
                     "startDate":"2021-10-26T08:00:00.000Z",
                     "lengthMinutes":120,
					 "description": "OnQueue Work",
					 "paid": true
                  },
                  {
                     "activityCodeId":"1",
                     "startDate":"2021-10-26T10:00:00.000Z",
                     "lengthMinutes":15,
					 "description": "Break",
					 "paid": true
                  },
				  {
                     "activityCodeId":"0",
                     "startDate":"2021-10-26T10:15:00.000Z",
                     "lengthMinutes":120,
					 "description": "OnQueue Work",
					 "paid": true
                  },
				  {
                     "activityCodeId":"2",
                     "startDate":"2021-10-26T12:15:00.000Z",
                     "lengthMinutes":30,
					 "description": "Meal",
					 "paid": false
                  },
				  {
                     "activityCodeId":"0",
                     "startDate":"2021-10-26T12:45:00.000Z",
                     "lengthMinutes":120,
					 "description": "OnQueue Work",
					 "paid": true
                  },
				  {
                     "activityCodeId":"1",
                     "startDate":"2021-10-26T14:45:00.000Z",
                     "lengthMinutes":15,
					 "description": "Break",
					 "paid": true
                  },
				  {
                     "activityCodeId":"0",
                     "startDate":"2021-10-26T13:00:00.000Z",
                     "lengthMinutes":60,
					 "description": "OnQueue Work",
					 "paid": true
                  },
               ],
               "manuallyEdited":true
            }
         ],
         "fullDayTimeOffMarkers":[
            
         ],
         "metadata":{
            "version":4
         }
      }
   ]
}

The request does upload the file to Genesys Cloud, here is the response I receive:


{
    "correlationId": "4f93dbeb-1976-4a5d-ab6b-3177440f6b40",
    "files": [
        "f026dbca-47c8-4c22-acb0-bb75f6288224.json.gz"
    ],
    "operationId": "f026dbca-47c8-4c22-acb0-bb75f6288224"
}

I am not seeing anything update in Genesys Cloud:

Am I missing something?

EDIT: Updated the request .json file and the response.

Thanks again,
Léandre

JSON can be a finicky format. I just copied your json into a validator and saw you have a trailing comma on your list of activities, which is not allowed in JSON.

See here for a tutorial on how to subscribe to notifications - The tutorial in question is for historical adherence queries, but the process is the same as it would be for updating schedules, excepting that the topic you want to watch for schedule updates is v2.workforcemanagement.businessunits.%s.schedules. Note you'll want to subscribe to the notifications before you send your update if you want to see the notification as notifications are not sent if there are no active subscriptions when they arrive.

I can create another topic if needed

Given that this topic is marked "resolved" now that would probably be best for ongoing discussion, though feel free to tag me for help if needed.

Hello,

Even after removing the comma, I have the same output. The schedule is not updated. (Correlation id : 96e02c50-3ae7-4fb9-bbbb-4bf2cc8fa2c5)

I'll try out subscribing to notifications in the followings days. I'll create another topic if I can't seem to find the answer to my problem.

Thanks a lot,
Leandre

Your problem in this case is you have bumped the metadata.version to 4. It should be the same as what is returned on the GET schedule, you should not bump it yourself.

For those who stumble on this post, here are the last reasons why it didn't work for me in addition to what @brian.trezise said above:

  • Make sure you stay consistent in the activity hours. In the snippet I gave, the last activity needs to start at "2021-10-26T15:00:00.000Z" not "2021-10-26T13:00:00.000Z", typo from my part.
  • (This one I am not exactly sure) Make sure you don't overlap on current shifts hours. If there is an overlap, it won't update the shift you overlapped with, it will just deny the request.
1 Like

You're right, overlapping shifts will be rejected as a validation error

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.