简体   繁体   中英

Microsoft graph api update event returns HTTP error 400 bad request

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 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. 在此处输入图像描述

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> "
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM