1

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"}
Md Farid Uddin Kiron
  • 16,817
  • 3
  • 17
  • 43
  • What information do you want to update? Are you trying in `CURL` or sending an object? It seems your request format is not correct. – Md Farid Uddin Kiron Jul 26 '22 at 06:14
  • I am trying to update the start, end, location, body, and attendees. I am sending this information using JSON. – Alyssa Capco Jul 26 '22 at 06:44
  • Please be sure when updating the time zone of the start or end time of an event, first find the supported time zones to make sure you set only time zones that have been configured for the user's mailbox server. [Check the special official note for this](https://learn.microsoft.com/en-us/graph/api/event-update?view=graph-rest-1.0&tabs=http#notes-for-updating-specific-properties) – Md Farid Uddin Kiron Jul 26 '22 at 07:01
  • If the posted answer resolves your question, please mark it as the answer by clicking the check mark. Doing so helps others find answers to their questions. See https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Shiva Keshav Varma Jul 26 '22 at 09:18

1 Answers1

1

Here the problem is with the properties of start property. 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 have dateTime and timeZone.

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 DateTime2 but according to documentation it has only those above two properties only, one of which is dateTime, so simply modify your JSON data property to dateTime and value to something like the format shared here with example.

Below screenshot is the sample JSON used from your data and it was successful. enter image description here

Modified JSON:

{
"subject": "X",
"start": {
    "timeZone": "W. Europe Standard Time",
    "dateTime": "2022-07-27T10:30:00.0000000"
},
"end": {
    "timeZone": "W. Europe Standard Time",
    "dateTime": "2022-07-27T11:30:00.0000000"
},
"location": {
    "uniqueIdType": "private",
    "displayName": "X",
    "locationType": "default",
    "uniqueId": "X"
},
"body": {
    "contentType": "html",
    "content": "<html> <body> <p>Afspraak met: X</p> <p>X ANTWERPEN </p> <p>E-mailadres: X</p> <p>Telefoonummer: X</p> <p>Klantnummer: 45</p> </body> </html> "
}

}

Shiva Keshav Varma
  • 3,398
  • 2
  • 9
  • 13