我正在使用Microsoft Graph API从Sharepoint列表中获取项目。一切运行良好,我有一个令牌,可以从列表中获取项目
现在,当该列表上的任何项目更新时,我想得到通知。为此,我尝试使用具有相同令牌的订阅创建webhook。但是,当尝试创建订阅时,API返回403。
var subscription = new Subscription
{
Resource = "sites/{siteId}/lists/{listId}/",
NotificationUrl = "{notification url}",
ExpirationDateTime = DateTimeOffset.Now.AddDays(2),
ChangeType = "updated"
};
var res = await graphServiceClient.Subscriptions
.Request()
.AddAsync(subscription);
我已经设置了我的应用程序注册所需的Sites.ReadWrite.All权限。对该API的调用返回了我
{
Error: Code: ExtensionError
Message: Operation: Create; Exception: [Status Code: Forbidden; Reason: Access denied. You do not have permission to perform this action or access this resource.]
Inner error:
AdditionalData:
request-id: 99445d24-8d09-45a5-98e7-05b99587fd7f
date: 2020-04-26T21:53:21
ClientRequestId: 99445d24-8d09-45a5-98e7-05b99587fd7f
}
我定位到错误的资源还是该应用程序需要其他权限?
编辑:也尝试使用证书进行授权,但仍然没有。
答案 0 :(得分:1)
对于创建new webhook subscription,应用程序必须至少对将在其中创建订阅的SharePoint列表具有编辑权限(如果应用程序是Azure AD)。如果应用程序是SharePoint加载项,则必须授予“管理”或更高的权限。