I was trying to create a webhook subcription for a particular document in Onedrive to get the request while the file is updated but I was not able to create the subscription. Here is my request
POST /v1.0/subscriptions HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer
Content-Type: application/json
Content-Length: 297
{
"changeType": "updated",
"notificationUrl": "https://contoso.azurewebsites.net/api/webhook-receiver",
"resource": "/me/drive/root:/file.xlsx",
"expirationDateTime": "2022-01-01T11:23:00.000Z",
"clientState": "client-specific string"
}
I am getting following response
{
"error": {
"code": "InvalidRequest",
"message": "resource '/me/drive/root:/file.xlsx' is not supported.",
"innerError": {
"date": "2021-12-08T16:49:12",
"request-id": "85ae70c6-2f43-422c-8e26-91ba749f08da",
"client-request-id": "85ae70c6-2f43-422c-8e26-91ba749f08da"
}
}
}
But when the resource field is changed to /me/drive/root (i.e for my drive root folder). Webhook Subscription is successfully created.
Here is my request body:
POST /v1.0/subscriptions HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer`
Content-Type: application/json
Content-Length: 282
{
"changeType": "updated",
"notificationUrl": "https://contoso.azurewebsites.net/api/webhook-receiver",
"resource": "/me/drive/root",
"expirationDateTime": "2022-01-01T11:23:00.000Z",
"clientState": "client-specific string"
}
I am getting following response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#subscriptions/$entity",
"id": "14bc7474-1493-4205-bc5e-ededbf5",
"resource": "/me/drive/root",
"applicationId": "f5a98a64-c08b-48c3-917a-f03c6466",
"changeType": "updated",
"clientState": "client-specific string",
"notificationUrl": "https://contoso.azurewebsites.net/api/webhook-receiver",
"notificationQueryOptions": null,
"lifecycleNotificationUrl": null,
"expirationDateTime": "2022-01-01T11:23:00Z",
"creatorId": "767b3902-2804-40d9-817d-5e58a681",
"includeResourceData": null,
"latestSupportedTlsVersion": "v1_2",
"encryptionCertificate": null,
"encryptionCertificateId": null,
"notificationUrlAppId": null
}
So can anyone suggest me with correct resource for webhook subscription for a particular document?