I am unable to create a calendar event with attachments using Office365's Rest API. Creating events without attachments is not a problem. Trying to create events with attachments creates the event, but the files I send are not added. The server responds with a 201 response code.
I am sending a POST request to:
https://graph.microsoft.com/v1.0/me/calendars/$(calendarID)/events
I use the following Authorization header:
Authorization: Bearer $(tokenString)
Request payload:
{
"start": {
"dateTime": "2017-09-27T20:00:00.000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2017-09-27T21:00:00.000",
"timeZone": "UTC"
},
"attendees": [
{
"emailAddress": {
"address": "person@example.com"
},
"type": "Required"
}
],
"subject": "Example subject",
"body": {
"content": "Example content",
"contentType": "Text"
},
"hasAttachments": true,
"sensitivity": "Normal",
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "$(fileName)",
"contentBytes": "$(base64EncodedString)"
}
]
}
I'm following the documentation at https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/calendar_post_events. My event follows the event schema, and the attachments follow the fileAttachment schema.
I have tried different values for @odata.type, removing hasAttachments from the request, as well as adding name, size, and contentType fields to the attachment. All of these give the same result - a 201 response, and an event created without attachments.
Any help would be much appreciated, thanks!