MK446
MK446

Reputation: 458

Receiving outlook rest push notification twice, when I create/update/delete the calender

I have a requirement that, I need to get notification whenever any calendar item is created/updated/deleted. I followed the Outlook push notification documentation to subscribe to calendar notifications.

I have successfully subscribed for calendar events. But whenever I create a new calendar, I am receiving notification twice. Below is the notification request data.

First notification request data:

{
    "value": [{
        "@odata.type": "#Microsoft.OutlookServices.Notification",
        "Id": null,
        "SubscriptionId": "OTA0N0MwQj==",
        "SubscriptionExpirationDateTime": "2017-09-27T05:30:49.6163119Z",
        "SequenceNumber": 1,
        "ChangeType": "Created",
        "Resource": "https://outlook.office.com/api/v2.0/Users('1520ed5a')/Events('AAMkADAzNDUxODY=')",
        "ResourceData": {
            "@odata.type": "#Microsoft.OutlookServices.Event",
            "@odata.id": "https://outlook.office.com/api/v2.0/Users('1520ed5a')/Events('AAMkADAzNDUxODY=')",
            "@odata.etag": "W/\"DwAAABYAAAB4h4N+ELBRSbQKq1A05YT8AADcUdIx\"",
            "Id": "AAMkADAzNDUxOD="
        }
    }]
}

Second notification request data:

{
    "value": [{
        "@odata.type": "#Microsoft.OutlookServices.Notification",
        "Id": null,
        "SubscriptionId": "OTA0N0MwQj==",
        "SubscriptionExpirationDateTime": "2017-09-27T05:30:49.6163119Z",
        "SequenceNumber": 2,
        "ChangeType": "Updated",
        "Resource": "https://outlook.office.com/api/v2.0/Users('1520ed5a')/Events('AAMkADAzNDUxODY=')",
        "ResourceData": {
            "@odata.type": "#Microsoft.OutlookServices.Event",
            "@odata.id": "https://outlook.office.com/api/v2.0/Users('1520ed5a')/Events('AAMkADAzNDUxODY=')",
            "@odata.etag": "DwAAABYAAAB4h4N+ELBRSbQKq1A05YT8AADcUdIy\"",
            "Id": "AAMkADAzNDUxOD="
        }
    }]
}

If you observe both requests data, in first request data it's showing ChangeType as Created and in second request data it's showing ChangeType as Updated.

Same behavior (getting notification twice) when I update or delete calendar.

Any Idea how to get rid of second notification?

Upvotes: 4

Views: 1124

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33094

This isn't the expected behavior and I've been unable to replicate it myself. My best guess is that you have some other system monitoring the calendar and automatically editing the calendar events. This would explain why you get an update almost immediately following your create action.

When it comes to syncing, would recommend making use of the /delta functionality from Microsoft Graph API. When you receive a notification, you would then simply pull the /delta and return only the records that have changed. If you're receiving a false notification this would eliminate duplicate processing since the result of your second /delta would be empty. If you there is a change, but not to a property you care about, you could then discard the result and eliminate any unnecessary writes to your data store.

Upvotes: 1

Related Questions