I want to subscribe to updates of the root drive of a SharePoint Site using Microsoft Graph. The problem I am encountering is that when you create a Subscription, you need to provide a resource string. However, the documentation is very unclear on what this resource string should be for the drive in a SharePoint site.
I tried using this as the resource path:
sites/{sp-domain},{sp-site-id},{sp-web-id}/drive
But it is returning a BadRequest. Have searched everywhere, no useful information in documentation or on the Internet so any help with this would be greatly appreciated.
As per this docs on Supported resources and this one on driveItem subscription, you have to add a path.
Instead of sites/{sp-domain},{sp-site-id},{sp-web-id}/drive
do sites/{sp-domain},{sp-site-id},{sp-web-id}/drive/root
. Here is a working HTTP Call
POST https://graph.microsoft.com/v1.0/subscriptions
{
"changeType": "updated",
"notificationUrl": "https://whook-url.com",
"resource": "sites/SITE-ID/drive/root",
"expirationDateTime": "2021-09-27T11:59:45.9356913Z",
"clientState": "secretClientValue",
"latestSupportedTlsVersion": "v1_2"
}