Graph Calendar API returning 500 when trying to creating an event
I am trying to add an event to a calendar using the graph API, my code was working 2 months ago but it has now stopped working, I am unsure exactly when it stopped working as I have not run it for a while.
I am getting a 500 "An internal server error occurred. The operation failed." error which is not very useful.
I am trying to add the event to a calendar that has been shared with a user inside my tenant, I have configured an app within my tenant and given it the Calendars.ReadWrite permission and I use this app to get the access through the Graph API.
I can successfully read the events from this calendar:
EventCollectionResponse? events = await _graphClient.Users[_calendarUserId].Calendars[calendarId].CalendarView.GetAsync(
(requestConfiguration) =>
{
requestConfiguration.QueryParameters.StartDateTime = fromUtc.ToString("O", CultureInfo.InvariantCulture);
requestConfiguration.QueryParameters.EndDateTime = toUtc.ToString("O", CultureInfo.InvariantCulture);
});
However I am getting a 500 when trying to add an event to this calendar:
Event? insertedEvent = await _graphClient.Users[_calendarUserId].Calendars[calendarId].Events.PostAsync(insertEvent);
The calendar has been shared with my user with read/write permission because I can log into outlook as that user and add events to the calendar.