Im trying to receive push notification on calendar events through microsoft graph
the notificationURL points to webservice which is running on NodeJS
subscription I have made has these options.
{
"changeType": "created,updated,deleted",
"notificationUrl": "myurl",
"resource": "users/userid/events?$filter=sensitivity%20eq%20%27Normal%27",
"expirationDateTime":"2016-11-05T18:23:45.9356913Z",
"clientState": "customclientstate"
}
however im getting multiple POST calls(2~4) coming from subscription(all of them having identical body) whenever a single event is changed.
there is only one subscription active, a single calendar, and i am responding to the request with status code 204 without any content(tested with postman).
its a huge problem since im updating DB whenever the request comes in.
has anyone run into this problem? ive been looking all over without any results.
any input would be greatly appreciated!! =).
Although clientState is not required, you must include it to comply with our recommended change notification handling process. Setting this property will allow you to confirm that change notifications you receive originate from the Microsoft Graph service.
Microsoft Graph allows apps to subscribe to change notifications for resources via webhooks. You can set up subscriptions to include the changed resource data (such as the content of a Microsoft Teams chat message or Microsoft Teams presence information) in change notifications.
Delta query enables applications to discover newly created, updated, or deleted entities without performing a full read of the target resource with every request. Microsoft Graph applications can use delta query to efficiently synchronize changes with a local data store.
I have this same issue. When creating new event in office calendar I'll get everytime one notification with ChangeType: Created
and at the same time three notifications with ChangeType: Updated
. When I'm cancelling event in office I get always 3 x Updated notifications and finally 1 x ChangeType: Deleted
.
What you can do here is to use ChangeKey validation. Everytime you get new notification from office you have to request that event from API, right?
Once you fetched that event you can check if event.ChangeKey property has changed.
It's same thing as etag in websites. If content changes, etag hash changes.
So when you get Created
notification, take that event's ChangeKey and store it to array or db and whenever you get notification remember to validate if you have that event's ID already in array or db and also if ChangeKey has changed. If ChangeKey is same as last time, you won't need to update that event in db.
This also works with recurring events, if even one occurrence has changed SeriesMaster event's ChangeKey also changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With