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!! =).
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.