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/[email protected]/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?

1 Answer 1

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/[email protected]/events", "clientState":"1486588355561", "expirationDateTime":"2018-11-20T18:23:45.9356913Z" }

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

Sign up to request clarification or add additional context in comments.

6 Comments

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 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 ([email protected])?
Okey lets se. First of we use this url to get admin consent login.microsoftonline.com/xxx.onmicrosoft.com/…. Then we get the access token here login.microsoftonline.com/xxx.onmicrosoft.com/oauth2/v2.0/token by posting client_id, client_secret, grant_type and scope=graph.microsoft.com/.default. Then we do whats written above. And its a Office 365 corporate account.
New request looks like this: { "changeType": "created,updated,deleted", "notificationUrl": "https:\/\/xxx.com\/push.php", "resource": "users\/[email protected]\/events", "clientState": "1486588355561", "expirationDateTime": "2018-11-20T18:23:45.9356913Z" }
@Ludvig there was an issue with app only tokens from the V2 auth endpoint that has been resolved, can you please try again?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.