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:
-
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)?
-
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
-
Could you please suggest anything else that looks suspicious or wrong?
Thank you in advance.
Irena