architectApi.postArchitectSchedules 400 error

We are trying to consume the APi architectApi.postArchitectSchedules, for this i have code snippet to set the body as input to this API and getting and error 400 bad request

var body = {
"name": "customer12x1x2",
"start": "2020-03-17T11:00:00.000",
"end": "2020-03-17T21:00:00.000",
"rrule": "FREQ=YEARLY;BYMONTH=3;BYMONTHDAY=17"
};
return architectApi.postArchitectSchedules({body1});

Error :- 1. body: {message: "[Request body must not be null]", code: "constraint.validation", status: 400}
2. error: Error: Bad Request at h.

I see two likely problems with your code regarding this line: return architectApi.postArchitectSchedules({body1});

  1. The extra curlys around the variable body1 shouldn't be there
  2. based on the example you provided, body1 is not defined. The variable body should be used here.

sorry, sample code i posted earlier is not bit messeup, here is the one i'm using

			var body = {
				"name":"customeredited1324",
				 "start": "2020-03-17T11:00:00.000", 
				"end": "2020-03-17T21:00:00.000",
				};

conversationsApi.postArchitectSchedules(body).then(function(result){
console.log("created successfullu");
console.log(result);
}).catch(function(error){
console.error("Error creatin schedulel", error);
});

Can you grab the correlation ID from the response?

inin-correlation-id: "dcdf37af-6889-47b7-bd74-ee525f5237b8"

Request sent : var body = {
"name":"customeredited13245a",
"start": "2020-03-17T11:00:00.000",
"end": "2020-03-17T21:00:00.000",
};
alert("calling the method");

conversationsApi.postArchitectSchedules(body).then(function(result){


when have tried the same format from "https://developer.mypurecloud.com/developer-tools/#/codeeditor" and that worked, only problem when i do this from my code

var body = {
"name":"customeredited1a23",
"start": "2020-03-17T11:00:00.000",
"end": "2020-03-17T21:00:00.000",

};
alert(body);

architectApi.postArchitectSchedules(body).then(function(result){

Maybe it's a problem with that line. The Conversations API doesn't have that method. Can you get the correlation ID from the response?

it is just the name i used, but referring to correct api class

const conversationsApi = new platformClient.ArchitectApi();

inin-correlation-id: "cfe7761a-eddc-4b40-89ef-ce924a582bdc" is this the one? if not please let me know where i can i find this?

The correlation ID doesn't show anything other than the error about not sending a body.

Especially since it works in one place and not the other, it seems likely that there's an error in your code somewhere. Also, make sure you're using the latest version of the SDK so the methods it offers match the current state of the API itself and the SDK documentation.

thank you for that suggestion, it worked, i was using older version of SDK, now updated my code to refer the latest version and it worked. you saved my day, thank you so much

1 Like

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