aherrick
aherrick

Reputation: 20169

Microsoft Graph API - CalendarView Delete Event

I'm trying to delete/cancel and event pulled from the CalendarView API for a given Conference Room. I have the Event ID and am trying the following:

graphClient.Users["[email protected]"]
   .CalendarView[eventId]
   .Request(options)
   .DeleteAsync()

Receiving the following error message:

Message: The OData request is not supported.

Is it not possible to delete/cancel associated from a CalendarView?

I've noticed when I create the event (under my user) it has a different ID than if I pull the same event from the CalendarView.

Thoughts? When pulling the CalendarView for each Conference Room I wouldn't have context to the organizers Events, correct?

Upvotes: 0

Views: 3412

Answers (2)

aherrick
aherrick

Reputation: 20169

Basic Code Sample:

            var query = new List<Microsoft.Graph.Option>()
                 {
                  new Microsoft.Graph.QueryOption("$filter", $"iCalUId eq '{eventId}'")
                 };

            var events = await graphClient.Users[User.Identity.Name].Events.Request(query).GetAsync();

            var evt = events.First();

            await graphClient.Users[User.Identity.Name].Events[evt.Id].Request().DeleteAsync();

Upvotes: 1

Jason Johnston
Jason Johnston

Reputation: 17692

To delete an event you need to use the /events segment, not /calendarview. You can get the ID from the calendar view, then just do:

graphClient.Users[""].Events[eventId].Request().DeleteAsync();

Upvotes: 3

Related Questions