Outlook: Developer Blog

Excel Microsoft Teams Office 365 OneDrive OneNote Outlook SharePoint

Microsoft Graph webhooks update – March 2016

Hi folks, we’ve got another incremental update for our Microsoft Graph webhooks preview on the journey towards shipping a production release.  First, I’m pleased to say we’ve rounded out the set of available operations with support for DELETE and PATCH, as well as POST and GET.

Now, you can delete an existing subscription with the following http code:

  DELETE https://graph.microsoft.com/beta/subscriptions/{id}  Authorization: Bearer <YourOAuthToken>  

And you can extend the expiration time on a subscription with the following simple patch command:

  PATCH https://graph.microsoft.com/beta/subscriptions/{id}  Authorization: Bearer <YourOAuthToken>  Content-type: application/json  {    "expirationDateTime" : "2016-03-16T18:23:45.9356913Z"  }  

Subscriptions to Outlook data will have a maximum expirationDateTime of 4230 minutes from the time of subscription creation. It’s a good idea to use this new PATCH functionality to extend your subscription well before it times out.

We’ve also made a couple of changes to the property names for working with subscriptions, so we’re more consistent across Microsoft APIs, and we’ve added a requirement to set the expirationDateTime explicitly when you create a subscription. Here’s the new code:

  POST https://graph.microsoft.com/beta/subscriptions  Content-type: application/json  Authorization: Bearer <YourOAuthToken>  {    "changeType": "created",    "notificationUrl": "[https://<YourAppURLHere>/api/webhookCallback%3c/a%3e&quot]https://<YourAppURLHere>/api/webhookCallback",    "resource": "me/messages",    "expirationDateTime" : "2016-03-16T18:23:45.9356913Z"  }  

If the request succeeds, the response will be:

  HTTP/1.1 201 Created  {    "@odata.context":"https://graph.microsoft.com/beta/$metadata#subscriptions/$entity",    "id":"7f105c7d-2dc5-4530-57cd-4e7af6534c03",    "resource":"me/messages",    "changeType":"created",    "notificationUrl":"https://<YourAppURLHere>/api/webhookCallback",    "expirationDateTime":"2016-03-16T18:23:45.9356913Z"  }  

If your expirationDateTime is beyond the range that the resource you asked for supports, then you’ll get a 400 error.

The eagle-eyed among you will notice we’ve changed the ‘subscriptionId’ property to be just ‘id’, and the ‘subscriptionExpirationDateTime’ to be just ‘expirationDateTime’.

We expect these changes to be the final ones to the API shape now before we go to production.

Enjoy the new APIS, and as always, reach out to us on Twitter with the #MicrosoftGraph hashtag with your feedback.

Gareth and the webhooks team.

filter-icon