1

Im using the Microsoft Graph to get calendar event with application permission. It works perfectly. Now Im trying to set up a subscription to listen to event changes however the normal v1.0 do not suport this. However beta, at least in the description, say it works.

From the page: https://graph.microsoft.io/en-us/docs/api-reference/beta/api/subscription_post_subscriptions

"Note: the /beta endpoint allows Application permissions as a preview feature for most resources."

So I tried this with the URL: https://graph.microsoft.com/beta/subscriptions

Sending in a json object like this:

{ "changeType":"created,updated,deleted", "notificationUrl":"https%3A%2F%2FXXX.com%2Fo365.php", "resource":"%2Fusers%2Fooom%40xxx.com%2Fevents", "clientState":"1486588355561", "expirationDateTime":"2018-11-20T18:23:45.9356913Z" }

Doing this I get the result:

{ "error": { "code": "BadRequest", "message": "Resource not found for the segment '/users/room@xxx.com/events'.", "innerError": { "request-id": "d9ca58b1-ee1f-4072-81d5-0f1a25dcdd45", "date": "2017-02-08T21:26:51" } } }

I have tried all types of combos in the resource but cant get it to work. Anybody that have an idea on how to do this?

Ludvig
  • 53
  • 1
  • 8

1 Answers1

0

The value of json properties don't need to be url encoded. The resource also doesn't need a '/' in front of "users" (although this isn't what is causing your issue).

Try changing your JSON to:

{ "changeType":"created,updated,deleted", "notificationUrl":"https://myurl.com/o365.php", "resource":"users/person@myemail.com/events", "clientState":"1486588355561", "expirationDateTime":"2018-11-20T18:23:45.9356913Z" }

Feel free to respond back if this doesn't address the issue.

Nick
  • 1,743
  • 6
  • 23
  • 38
  • If i do that I get this error:{ "error": { "code": "InternalServerError", "message": "Object reference not set to an instance of an object.", "innerError": { "request-id": "2860b6b2-70fd-4b09-bc37-3ff529f77399", "date": "2017-02-13T20:24:34" } } } – Ludvig Feb 13 '17 at 20:25
  • @Ludvig A couple of things: 1. Could you share the new request body you are using? 2. Are you using the AuthV2 endpoint? 3. Is the subscription you are trying to create for an MSA account (outlook, hotmail, etc.) or a work account (user@my-tenant.com)? – Nick Feb 13 '17 at 23:15
  • Okey lets se. First of we use this url to get admin consent https://login.microsoftonline.com/xxx.onmicrosoft.com/adminconsent?client_id=XXX&state=XXX&redirect_uri=http://xx. Then we get the access token here https://login.microsoftonline.com/xxx.onmicrosoft.com/oauth2/v2.0/token by posting client_id, client_secret, grant_type and scope=https://graph.microsoft.com/.default. Then we do whats written above. And its a Office 365 corporate account. – Ludvig Feb 17 '17 at 12:58
  • New request looks like this: { "changeType": "created,updated,deleted", "notificationUrl": "https:\/\/xxx.com\/push.php", "resource": "users\/room@xxx.com\/events", "clientState": "1486588355561", "expirationDateTime": "2018-11-20T18:23:45.9356913Z" } – Ludvig Feb 17 '17 at 13:05
  • @Ludvig there was an issue with app only tokens from the V2 auth endpoint that has been resolved, can you please try again? – Nick Feb 17 '17 at 23:27
  • Works like a charm. Great that you found the issue. Thanks Nick – Ludvig Feb 19 '17 at 12:44