Architect API Giving Unexpected Error When Creating Schedule

I am using this API call to try to programmatically create a schedule:

https://developer.genesys.cloud/devapps/api-explorer#post-api-v2-architect-schedules

I get an error when I try to use this API through the .NET SDK. Here is my code:

var scheduleRequestBody = new Schedule();
scheduleRequestBody.Name = "Test Schedule Test";
scheduleRequestBody.Start = DateTime.Parse("2023-03-24T00:00:00.000");
scheduleRequestBody.End = DateTime.Parse("2023-03-24T23:59:00.000);

try
{
Schedule createdSchedule = _architectApiInstance.PostArchitectSchedules(scheduleRequestBody);
listOfCreatedSchedules.Add(createdSchedule);
}
catch (Exception ex)
{
Console.Writeline("Exception :" + ex.Message);
}

Here is my schedule Request Body:

image

I get this error:

Error calling PostArchitectSchedules: {"message":"The request could not be understood by the server due to malformed syntax.","code":"bad.request","status":400,"contextId":"...(context ID shown here)...","details":[],"errors":[]}

I can successfully make this call using the API explorer with the same API call and same input values. The only difference I see is that the type of the start and end fields when using the API Explorer is string, whereas the type when using the .NET SDK is DateTime (that is what the .NET SDK expects based on its definition for Schedule).

Does anyone have any ideas for how to overcome this issue?

Thanks!

The only answer I can give without this information is that something in your request is malformed in some way.

Thanks for the response! Here the Exception message in its entirety:

Error calling PostArchitectSchedules: {"message":"The request could not be understood by the server due to malformed syntax.","code":"bad.request","status":400,"contextId":"3d3ae08d-1ea3-44f6-a0fe-b176848ef271","details":[],"errors":[]}

I am using the same values for the 3 required fields across the .NET SDK and the API Explorer. And I am using the standard .NET SDK functions to set the attributes (versus forming my own JSON). Is it possible to confirm that the difference in the types is not the issue? Or is there a working example I can look at for reference?

The screenshot below shows the same values I use in the API Explorer, where this call works.

Please open a case with Care about this for two bug reports:

  1. The API resource has a bug and it's not passing the actual error back to you. The root error is "Error code [bad.request] type [IllegalArgumentException] message [Invalid format: "2023-03-24T07:00:00Z" is malformed at "Z"] cause type [] cause message []",
  2. To report that this API resource is failing to parse a valid ISO-8601 timestamp that doesn't contain a timezone. Z is the designator for no timezone and is part of the ISO-8601 standard. It should handle this.

You'll need to work around this by creating your own request body that doesn't have the Z at the end. You can make manual requests using the SDK by using ApiClient.CallAPI(...).

Hi Tim!

Got it. Thanks for your help :slight_smile:

No problem! BTW, if you get pushback from Care on the second item ask them to come talk to me. I have a hunch that the discussion of whether or not Z is a timezone might get a bit pedantic and contentious. :slight_smile:

Got it. Will do!