如何使用 Microsoft Graph 订阅 SharePoint 网站根驱动器的更新

How to subscribe to updates to the root drive of a SharePoint Site using Microsoft Graph

我想使用 Microsoft Graph 订阅 SharePoint 网站的根驱动器更新。我遇到的问题是,当您创建一个订阅时,您需要提供一个资源字符串。但是,关于 SharePoint 站点中驱动器的资源字符串应该是什么,文档非常不清楚。

我试过使用这个作为资源路径:

sites/{sp-domain},{sp-site-id},{sp-web-id}/drive

但是它正在返回 BadRequest。到处搜索,文档或 Internet 上没有有用的信息,因此非常感谢任何帮助。

根据 Supported resources and this one on driveItem subscription 上的文档,您必须添加路径。

而不是 sites/{sp-domain},{sp-site-id},{sp-web-id}/drivesites/{sp-domain},{sp-site-id},{sp-web-id}/drive/root。这是一个有效的 HTTP 调用

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"
}