I am following the doco on: https://learn.microsoft.com/en-us/graph/webhooks
I want to create a subscription to call a webhook every time an event in a shared mailbox is created or updated.
I think it will be something like this below. Can anyone give me an example of how I can configure the RESOURCE parameter, to be my shared mailbox and events?
POST https://graph.microsoft.com/v1.0/subscriptions
Content-Type: application/json
{
"changeType": "created,updated",
"notificationUrl": "https://mywebhook.com",
"resource": "/me/mailfolders('inbox')/messages",
"expirationDateTime": "2050-03-20T11:00:00.0000000Z",
"clientState": "SecretClientState"
}
Try to set the resource parameter to /users/yourSharedMailBox#yourTenant.com/events
Related
I'm looking through the Microsoft documentation on Subscription objects (https://learn.microsoft.com/en-us/graph/webhooks). I want to receive a notification for when a user changes their Profile Picture (photo property)
I sent the following subscription request, and I am successful in receiving notification when I update user properties, but not when I change their picture:
POST /v1.0/subscriptions HTTP/1.1
Host: graph.microsoft.com
Content-Type: application/json
Authorization: Bearer <TOKEN>
{
"changeType": "updated",
"notificationUrl": "https://00000.ngrok.io/listen",
"resource": "/users",
"expirationDateTime": "2020-12-09T11:00:00.0000000Z",
"clientState": "SecretClientState"
}
Response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#subscriptions/$entity",
"id": "00000000-0000-0000-0000-000000000000",
"resource": "/users",
"applicationId": "00000000-0000-0000-0000-000000000000",
"changeType": "updated",
"clientState": "SecretClientState",
"notificationUrl": "https://00000.ngrok.io/listen",
"lifecycleNotificationUrl": null,
"expirationDateTime": "2020-12-09T11:00:00Z",
"creatorId": "00000000-0000-0000-0000-000000000000",
"includeResourceData": null,
"latestSupportedTlsVersion": "v1_2",
"encryptionCertificate": null,
"encryptionCertificateId": null
}
Is there a way to subscript to photo changes in the Microsoft Graph in aggregate? Or do I have to subscribe to each user individually?
Reading and updating a user's profile photo is only possible if the user has a mailbox. Additionally, any photos that may have been previously stored using the thumbnailPhoto property (using the Azure AD Graph or through AD Connect synchronization) are no longer accessible through the Microsoft Graph photo property of the user resource. Microsoft documentation Microsoft Graph API limitation talks about it, refer "photo restrictions" section.
I've successfully created a webhook subscription to listen for changes on a shared calendar (I got a 201 Created response back from the create subscription endpoint) with the following POST body:
{
"changeType": "created,updated,deleted",
"notificationUrl": <my_https_app_webhook_url>,
"resource": "/me/calendars/<calendar_id>/events",
"expirationDateTime": "2020-03-06T12:30:27.606347+00:00",
"clientState": <secret_token>
}
If I then create an event on that shared calendar with 1 attendee (aside from myself, the organizer & owner of the shared calendar) and that attendee declines the event, I don't receive a notification at my subscription notificationUrl.
Am I missing something here?
{
"changeType": "created,updated",
"notificationUrl": "https://mynotification.url.com",
"resource": "users/adminuser#oadmin.onmicrosoft.com/events",
"expirationDateTime":"2020-03-03T14:09:27.121Z",
"latestSupportedTlsVersion": "v1_2"
}
Make sure you have added,ChangeType:created,updated
This is an expected behavior as the attendee's responses do not update the event object itself, thus not triggering a notification.
I'd recommend you add this as a suggestion to UserVoice
If i have Calendars.Read application permission for events in user calenders, how do i create a subscription to a user calendar using graph api.
below i tried to create event subscription for 'user#mydomain.com' mailbox by updating resource parameter to 'users/user#mydomain.com/events' and is this the right way to subscribe get notifications of shared,delegated calendars of user?
{
"changeType": "created,updated",
"resource": "users/user#mydomain.com/events",
"notificationUrl": "https://webhook.azurewebsites.net/api/send/myNotifyClient",
"expirationDateTime":"2016-11-20T18:23:45.9356913Z",
"clientState": "secretClientValue"
}
(Clarification: I have never created a notification for a resource of this type).
You did not state what the error was.
In your resource field it might need to be:
/users/{userId}/events
The {userId} should not be a UPN but the UUID of the user.
{
"changeType": "created,updated",
"resource": "users/{userId}/events",
"notificationUrl": "https://webhook.azurewebsites.net/api/send/myNotifyClient",
"expirationDateTime":"2016-11-20T18:23:45.9356913Z",
"clientState": "secretClientValue"
}
We are using a multitenant application.
We created a subscription to listen to calendar events for a particular user, but we are not receiving the notifications.
The user accepted the following scopes: Calendars.Read Calendars.ReadWrite Calendars.Read.Shared Calendars.ReadWrite.Shared offline_access User.Read.All
When we call to POST https://graph.microsoft.com/v1.0/subscriptions
BODY:
{
"resource": "/users/31c61efc-bc28-4552-9f0d-1a8735767c4e/calendars/AAMkAGRjZjY3OGRmLWU3MjAtNGExYy1hOTk0LTNkNjExOWVhZmYyNQBGAAAAAAD3yBF0B84VRJLe9CCZ4-ajBwDf5J1F10FqQ6VkC14neUWZAAAAAAEGAADf5J1F10FqQ6VkC14neUWZAABEL_2XAAA\u003d/events",
"changeType": "created,updated,deleted",
"clientState": "XXXXXX",
"notificationUrl": "https://XXXXX.ngrok.io/notification/event",
"expirationDateTime": "2019-05-31T14:42:08.651Z"
}
Then the notificationUrl is called and we receive the validation token:
Validation: Testing client application reachability for subscription Request-Id: 9d020355-7589-4485-ba29-62d1ec899723
But when we login into the 31c61efc-bc28-4552-9f0d-1a8735767c4e account and update or create an event, no notification is beign sent.
If we call to GET https://graph.microsoft.com/v1.0/subscriptions the subscription is created:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#subscriptions",
"value": [
{
"id": "b92d909e-b1b5-49b8-af54-74b7956d6565",
"resource": "/users/31c61efc-bc28-4552-9f0d-1a8735767c4e/calendars/AAMkAGRjZjY3OGRmLWU3MjAtNGExYy1hOTk0LTNkNjExOWVhZmYyNQBGAAAAAAD3yBF0B84VRJLe9CCZ4-ajBwDf5J1F10FqQ6VkC14neUWZAAAAAAEGAADf5J1F10FqQ6VkC14neUWZAABEL_2XAAA=/events",
"applicationId": "XXXX",
"changeType": "created,updated,deleted",
"clientState": null,
"notificationUrl": "https://XXXX.ngrok.io/notification/event",
"expirationDateTime": "2019-05-31T14:42:08.651Z",
"creatorId": "31c61efc-bc28-4552-9f0d-1a8735767c4e"
}
]
}
Monitoring the ngrok calls, there is no failing call to the notification events endpoint.
Is there any console log we can verify to understand what the problem could be?
We tried to create subscriptions for different accounts with no success.
We also tried to subcribe to /me/events
Just wondering if it could the cause, but the calendar id to whom you're subscribing to is ending with \u003d instead of =. Encoding stuff. Might not be it, but for me its working well with this.
Hope its just this!
JS
When I attempt to create a Microsoft Graph webhook subscription to the security/alerts endpoint, the subscription creation fails with a generic message as shown below. Modifying the resource to 'me/messages' results in a successful webhook subscription created, so this appears to be specific to the security/alerts endpoint. How do I move past this?
The body of the request is as such:
{
"changeType": "created",
"notificationUrl": "https://xxxxxxxxx.azurewebsites.net/api/graphnotifications",
"resource": "security/alerts?$filter=vendorInformation/provider+eq+'ASC'",
"expirationDateTime": "2018-11-15T11:00:00.0000000Z",
"clientState": "secretClientValue"
}
Please use 'updated' for 'changeType'. Security/Alerts uses 'updated' for all new or updated alerts.
Wes, you didn't post the URL that you sent that request to. As per the documentation for Security Alerts.
You can use Microsoft Graph webhooks to subscribe to and receive notifications about updates to Microsoft Graph Security entities.
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/security-api-overview
On that page, it states posting a request and gives a sample like this
POST https://graph.microsoft.com/v1.0/subscriptions
Content-Type: application/json
{
"changeType": "created,updated",
"notificationUrl": "https://webhook.azurewebsites.net/notificationClient",
"resource": "/me/mailfolders('inbox')/messages",
"expirationDateTime": "2016-03-20T11:00:00.0000000Z",
"clientState": "SecretClientState"
}
https://developer.microsoft.com/en-us/graph/docs/concepts/webhooks
Are you posting that request body to that url?