Update schedule using signed URL fails

Hello,

We are looking into implementation of updating and importing agents' schedules using the newer approach, as described in this post. We have a working functionality for updating a single agent schedule using the previous documented approach and as the first phase for conversion we attempt to update a single agent schedule. The update consistently fails for us, as seen from notifications, we are trying to understand the reason for this. Our data we try to upload is:

  "agentSchedules": [
    {
      "userId": "bfae588a-304e-4e43-84e4-2e28b49978e4",
      "shifts": [
        {
          "activities": [
            {
              "activityCodeId": "0",
              "startDate": "2022-07-17T22:30:00.000Z",
              "lengthMinutes": 120,
              "description": "",
              "paid": true
            },
            {
              "startDate": "2022-07-18T00:30:00.000Z",
              "lengthMinutes": 15,
              "description": "",
              "activityCodeId": "1",
              "paid": true
            },
            {
              "activityCodeId": "0",
              "startDate": "2022-07-18T00:45:00.000Z",
              "lengthMinutes": 120,
              "description": "",
              "paid": true
            },
            {
              "startDate": "2022-07-18T02:45:00.000Z",
              "lengthMinutes": 30,
              "description": "",
              "activityCodeId": "2",
              "paid": false
            },
            {
              "activityCodeId": "0",
              "startDate": "2022-07-18T03:15:00.000Z",
              "lengthMinutes": 165,
              "description": "",
              "paid": true
            },
            {
              "startDate": "2022-07-18T06:00:00.000Z",
              "lengthMinutes": 15,
              "description": "",
              "activityCodeId": "1",
              "paid": true
            },
            {
              "activityCodeId": "0",
              "startDate": "2022-07-18T06:15:00.000Z",
              "lengthMinutes": 60,
              "description": "",
              "paid": true
            }
          ],
          "manuallyEdited": true,
          "id": "0"
        }
      ],
      "fullDayTimeOffMarkers": []
    }
  ]
}

The code snippet, using JavaScript SDK is:

    const compressedChanges = zlib.gzipSync(Buffer.from(JSON.stringify(changes)));

    const { url, uploadKey, headers } =
      await workforceManagementApiInstance.postWorkforcemanagementBusinessunitWeekScheduleUpdateUploadurl(
        businessUnitId,
        weekDateId,
        scheduleId,
        {
          contentLengthBytes: compressedChanges.length,
        },
      );

    const response = await axios.put(url, compressedChanges, {
      headers,
    });

    await workforceManagementApiInstance.postWorkforcemanagementBusinessunitWeekScheduleUpdate(
      businessUnitId,
      weekDateId,
      scheduleId,
      { uploadKey },
    );


Questions:

  1. Is it possible to get an example of working input data? Does our data have all necessary fields for the newer approach (we use the content similar to the one used in previous existing update, except skipping metadata)?

  2. Is the gzipping of the data correct as well as getting the number of bytes to be sent? Do you have a working example of gzipping for this request

  3. Could you please suggest anything else that looks suspicious or wrong?

Thank you in advance.

Irena

Hi Irena,

Could you provide a bit more information?

I.e.,:

  • The actual error that comes across the notification
  • Correlation Id (should be a response header on the enqueue request)

Hi @Langsford_Jay ,

Thank you for looking into it.

The error in notifications is only "status": "Error", in addition to operationId and eventType.

Here is an ININ-Correlation-Id from one of the failing requests header: f51e9647-f380-4191-a224-42c042dc65c7

A few more from the notification channel event cards (using tools in documentation to listen to notifications )
e4c657b2-c279-41ab-a005-7075ed301c5f
caeb07e0-1107-4b59-adfe-0497ca486aef
eb8bd489-e8ef-4d8c-83a7-1c31108d8c7d

From wss://streaming.mypurecloud.com.au/channels/streaming-4-jcc8krota2re85odmr60p3a7bv

One thing you can check when you get a notification with "Error" status is the notification's metadata (this is distinct from any metadata fields potentially present in the actual event body schema), similar to headers on an HTTP response. The details of what went wrong are included there.

In your specific case it appears the schedule you're uploading is failing validation due to a missing metadata field (distinct from the notification metadata) somewhere. Note that the agentSchedules.metadata.version property is unique per agent schedule and is a required field for updating or deleting agent schedules, and that there is also a top level metadata field for the schedule as a whole. The schema for the upload is documented here:

POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekId}/schedules/{scheduleId}/update/uploadurl

Thank you @brian.trezise , @Langsford_Jay for looking into it! Was able to make it work correctly based on your input. Many thanks for the help.

1 Like

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