Microsoft Graph APi not returning "Cancelled" Events - microsoft-graph-api

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

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.

I just tried
https://graph.microsoft.com/v1.0/Users/xx/Calendar/Events/xx/instances
?startDateTime=2020-02-17&endDateTime=2020-03-01&isCancelled=true
and what came back are all the non-cancelled events...
Ditto isCancelled=false
leaving off the &isCancelled=xx parameter returns all the events with the isCancelled attribute set to false for everything.

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();

Related

How to create subscription for specific event of Graph API

I want to get notifications on a specific event that I have created from my application. For that, I am using the below code to subscribe to a specific event.
var subscription = new Subscription
{
ChangeType = "updated,deleted",
NotificationUrl = $"{_notificationHost}/listen",
Resource = "me/events/{event-id}",
ClientState = Guid.NewGuid().ToString(),
IncludeResourceData = false,
// Subscription only lasts for one hour
ExpirationDateTime = DateTimeOffset.UtcNow.AddHours(1)
};
But while creating it throws an exception:
Error creating subscription: Code: ExtensionError Message: Operation:
Create; Exception: [Status Code: BadRequest; Reason: The value
'https://outlook.office365.com/api/beta/Users('{userid}')/Events('{event-id}')'
of parameter 'Resource' is not supported.]
Just ran into this same issue. It looks like the Subscription API doesn't support subscriptions on specific events, only the entire calendar. There's an example for subscriptions to events in the "Resources examples" section, which looks like exactly what you want: me/events. The ID of the updated/deleted event is included in the callback, so if you only care about certain events, you can use that.

Create Microsoft Graph Api Subscription for accept/reject meeting event by attendees

In my project, I have created Rest API project to create subscription and to listen notification from Microsoft Graph API.
I want subscription for following things:
When I create meeting room event then I want to get notification if any attendees accept/reject that meeting room event.
If whole meeting event is cancelled or moves to another time slot or added any new attendees.
I was expecting all above gets covered by following code but it is not :
var subscription = new Subscription
{
ChangeType = "updated,deleted",
NotificationUrl = $"{_notificationHost}/listen",
Resource = "me/events",
ClientState = Guid.NewGuid().ToString(),
IncludeResourceData = false,
// Subscription only lasts for one hour
ExpirationDateTime = DateTimeOffset.UtcNow.AddHours(1)
};
It does not send notification when accept or reject done by attendee with 'Do not send a response'. How I can get notification for this?
I managed both scenarios :
I am getting notification for attendees's reject/approve response on my listen api : NotificationUrl = $"{_notificationHost}/listen",
If new attendess added/removed or meeting time change or meeting cancelled then also we can get notification in Listen api.

Deleted Scheduled Messages still sending

I am building a slack application that will schedule a message when someone posts a specific type of workflow in a channel.
It will schedule a message, and if someone from a specific group of users replies before it has sent, it will delete the scheduled message.
Unfortuantely these messages are still sending, even though the list of scheduled messages is empty and the response when deleting the message is a successful one. I am also deleting the message within the 60 second limit that is noted on the API.
Scheduling the message gives me a success response, and if I use the list scheduled messages I get:
[
{
id: 'MESSAGE_ID',
channel_id: 'CHANNEL_ID',
post_at: 1620428096, // 2 minutes in the future for testing
date_created: 1620428026,
text: 'thread_ts: 1620428024.001300'
}
]
Canceling the message:
async function cancelScheduledMessage(scheduled_message_id) {
const response = await slackApi.post("/chat.deleteScheduledMessage", {
channel: SLACK_CHANNEL,
scheduled_message_id
})
return response.data
}
response.data returns { "ok": true }
If I use the list scheduled message API to retrieve what is scheduled I get an empty array []
However, the message will still send to the thread.
Is there something I am missing? I have the proper scopes set up and the API calls appear to be working.
If it helps, I am using AWS Lambda, and DynamoDB to store/retrieve the thread_ts and message IDs.
Thanks all.
For messages due in 5 minutes or less, chat.deleteScheduleMessage has a bug (as of November 2021) [1]. Although this API call may return OK, the actual message will still be delivered due to the bug.
Note that for messages within 60 seconds, this API does return an proper error code, as described in the documentation [2]. For the range (60 seconds, ~5 minutes), the API call returns OK but fails behind the scenes.
Before this bug is fixed, the only thing one can do is to only delete messages scheduled 5 minutes (the exact threshold may vary, according to Slack) or more (yes not very ideal and may not be feasible for some applications).
[1] Private communication with Slack support.
[2] https://api.slack.com/methods/chat.deleteScheduledMessage

Does Outlook graph api cache events?

I am making a call to the graph api to get a specific event:
return await graphClient.Me.Events[ExternalID]
.Request()
.Expand(singleValueExtendedPropertyExpandString)
.GetAsync()
.ConfigureAwait(false);
The event is properly returned. However, when I try to get the instances for the event:
var instanceException = (await graphClient.Me.Events[ExternalID].Instances
.Request(queryOptions)
.GetAsync()
.ConfigureAwait(false))
.Where(i => i.Type == EventType.Exception)
.FirstOrDefault();
I get an error from the graph API: "The specified object was not found in the store.".
I used the graph explorer to search for the particular event (with the url: https://graph.microsoft.com/v1.0/me/events/EXTERNALID) and also received the message that the object could not be found.
I have rerun the code several times and returned the event on the first GET only to receive an error on the second GET.
Has anyone experienced this before? Does the graph api cache GET results?
Does the event appear in the calendar in Outlook or teams' client?
I have faced this issue when creating an event through graph API and sometimes it returns a success response with the event data but the event doesn't appear in either calendars and returns the same error you posted when trying to query it.

Calendar ID in create response differs from what Graph stores

We are experiencing inconsistencies with calendar ID's.
When sending a POST to https://graph.mircrosoft.com/v1.0/me/calendars with the following payload
{ name: 'Calendar' }
We receive this reponse from which we store the id
{
:"#odata.context"=>"https://graph.microsoft.com/v1.0/$metadata#users('user%40outlook.com')/calendars/$entity",
:id=>"AQMkADAwATMwMAItMjE5ZC01YjYyLTAwAi0wMAoARgAAA1D6u4KwtRdMm1rAZoOEKvAHAMf0BP7S_89KmnrxCgze9tcAAAIBBgAAAMf0BP7S_89KmnrxCgze9tcAAAEBKdoAAAA=",
:name=>"Calendar",
:color=>"auto",
:changeKey=>"x/QE/tL7z0qaevEKDN721wAAAAAOFQ==",
:canShare=>true,
:canViewPrivateItems=>true,
:canEdit=>true,
:owner=>{:name=>"User", :address=>"user#outlook.com"}
}
When we attempt to create events into this calendar errors are being thrown as that ID does not exist. Looking into it further and making a GET request to https://graph.mircrosoft.com/v1.0/me/calendars we receive this payload (truncated for brevity)
{
:id=>"AQMkADAwATMwMAItMjE5ZC01YjYyLTAwAi0wMAoARgAAA1D6u4KwtRdMm1rAZoOEKvAHAMf0BP7S_89KmnrxCgze9tcAAAIBBgAAAMf0BP7S_89KmnrxCgze9tcAAAIjxAAAAA==",
:name=>"Calendar",
:color=>"auto",
:changeKey=>"I8E7t/aNjEqDHtJJL1UC6AAADFI=",
:canShare=>true,
:canViewPrivateItems=>true,
:canEdit=>true,
:owner=>{:name=>"User", :address=>"user#outlook.com"}}]
}
After diffing both ID's, we notice they differ. The interesting part of this is that this only happens with a handful of users and isn't an issue with most accounts. Is there a better way to keep track of specific calendars that we can continue to sync into? I'd hate to have to ping for calendars every time we'd like to fire off a CRUD action.

Resources