Reputation: 365
I am trying to get all the events in a Conference room's calendar with Microsoft graph API, given a startDateTime and endDateTime. I tried the following API's -
1. https://graph.microsoft.com/v1.0/users/{id}/events?startDateTime=2017-03-20T05:00:00.0000000&endDateTime=2017-04-06T21:00:00.0000000
2.https://graph.microsoft.com/v1.0/users/{id}/calendar/calendarView?startDateTime=2017-03-20T05:00:00.0000000&endDateTime=2017-04-06T21:00:00.0000000
The response includes all events with isCancelled=false. How do I fetch events which were Cancelled?
&$filter=isCancelled%20eq%20true
also returned empty as there are no events with isCancelled=true
in response
Upvotes: 7
Views: 3050
Reputation: 861
If you don't mind using the beta API, you can use it to get cancelled or modified events for a master recurring event. You can make the following request(make sure to add $expand=exceptionOccurrences
query string at the end):
GET https://graph.microsoft.com/beta/me/events/AAMkADAGAADDdm4NAAA=?$expand=exceptionOccurrences
You can find the cancelled items in cancelledOccurrences
which will be of the format <id>-<date>
and you can probably use the date to figure out which one was deleted. The modified instances are in exceptionOccurrences
.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#users('d1a2fae9-db66-4cc9-8133-2184c77af1b8')/events(subject,start,end,occurrenceId,exceptionOccurrences,cancelledOccurrences)/$entity",
"@odata.etag":"W/\"y53lbKh6jkaxHzFwGhgyxgAAw5zhug==\"",
"id":"AAMkADAGAADDdm4NAAA=",
"subject": "Daily stand-up",
"cancelledOccurrences": [
"OID.AAMkADAGAADDdm4NAAA=.2020-04-30",
"OID.AAMkADAGAADDdm4NAAA=.2020-05-07",
"OID.AAMkADAGAADDdm4NAAA=.2020-05-14"
],
"occurrenceId": null,
"start": {
"dateTime": "2020-04-23T11:30:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2020-04-23T12:00:00.0000000",
"timeZone": "UTC"
},
"exceptionOccurrences": [
{
"id": "AAMkADM0ZGRhMjdjLTA==",
"Subject": "SM update 24",
"occurrenceId": "OID.AAMkADAGAADDdm4NAAA=.2020-05-21",
"start": {
"dateTime": "2020-05-21T11:30:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2020-05-21T12:00:00.0000000",
"timeZone": "UTC"
}
}
]
}
Upvotes: 0
Reputation: 53
I was trying to fetch event after getting notification when event cancelled. I am trying with notification resource url and it throws exception: Microsoft.Graph.ServiceException: Code: ErrorItemNotFound. What I was expecting that response with notfound status code rather than throwing exception.
My code for fetching event:
var request = new EventRequest(
$"{_graphClient.BaseUrl}/{notification.Resource}",
graphClientApp,
null);
var message = await request.GetResponseAsync();
var response = await message.GetResponseObjectAsync();
Upvotes: 0
Reputation: 2883
By design, when an event is canceled, it is deleted from the calendar. So, there isn't a way today to query list of events that are deleted. We have an item in our backlog for supporting deleted events, but no timeline.
Upvotes: 4