I am using MS Graph API in Pega 8.6.4 to update an event start and end date, attendees, and location if needed using PATCH but would always get an HTTP error 400 BAD REQUEST. Not sure what is going on since in my application I am able to create an event and cancel it.
Request data:
{Request Message={"subject":"X",
"start":{"timeZone":"W. Europe Standard Time","DateTime2":"20220727T103000.000 GMT"},
"end":{"timeZone":"W. Europe Standard Time","DateTime2":"20220727T113000.000 GMT"},
"location":{"uniqueIdType":"private","displayName":"X","locationType":"default","uniqueId":"X"},
"body":{"contentType":"html",
"content":"<html> \t<body> \t\t<p>Afspraak met: X</p> \t\t<p>X \nANTWERPEN </p> \t\t<p>E-mailadres: X</p> \t\t<p>Telefoonummer: X</p> \t\t<p>Klantnummer: 45</p> </body> </html> "}}}
Method: PATCH
URL: https://graph.microsoft.com/v1.0/users/{userprincipalname}/events/{EventID}
Request header: {Content-Type = "application/json"}
Here the problem is with the properties of
startproperty. As you can see this documentation of event object, there is a property called start to specify the start time of an event. If you obseve, it is of type DateTimeTimeZone object. If you check the properties for this object, you can see that we havedateTimeandtimeZone.Now just if you compare these properties with the data you are giving in JSON, you can see that in your JSON data the property is
DateTime2but according to documentation it has only those above two properties only, one of which isdateTime, so simply modify your JSON data property todateTimeand value to something like the format shared here with example.Below screenshot is the sample JSON used from your data and it was successful.
Modified JSON:
}