Sharepoint 此页的安全验证无效,可能已损坏。请使用您的网络浏览器';单击“上一步”按钮重试您的操作

Sharepoint 此页的安全验证无效,可能已损坏。请使用您的网络浏览器';单击“上一步”按钮重试您的操作,sharepoint,sharepoint-2013,webhooks,sharepoint-rest-api,Sharepoint,Sharepoint 2013,Webhooks,Sharepoint Rest Api,我正在尝试为sharepoint列表创建web挂钩。不幸的是,这样做的唯一方法是通过调用API。因此,我调用API来创建我自己的web钩子,以在sharepoint网站中创建自定义列表 在我的sharepoint网站中,我在Chrome中打开了开发工具,并使用了以下代码: fetch(“https://my-org.sharepoint.com/sites/my-site/_api/web/lists('list-id')/订阅“{ “标题”:{ “接受”:“应用程序/json”, “内容类型”

我正在尝试为sharepoint列表创建web挂钩。不幸的是,这样做的唯一方法是通过调用API。因此,我调用API来创建我自己的web钩子,以在sharepoint网站中创建自定义列表

在我的sharepoint网站中,我在Chrome中打开了开发工具,并使用了以下代码:

fetch(“https://my-org.sharepoint.com/sites/my-site/_api/web/lists('list-id')/订阅“{
“标题”:{
“接受”:“应用程序/json”,
“内容类型”:“应用程序/json”,
},
“正文”:“{\”资源\”:”https://my-org.sharepoint.com/sites/my-site/_api/web/lists('list-id')\,\“notificationUrl\”:\“http://my-ngrok-id.ngrok.io\“,\“expirationDateTime\”:\“2021-11-03T21:54:41.000\”,
“方法”:“发布”,
});
但它给出了一个
403
错误:

{
“odata.error”:{
“代码”:“-2130575251,Microsoft.SharePoint.SPException”,
“信息”:{
“郎”:“恩我们”,
“值”:“此页的安全验证无效,可能已损坏。请使用web浏览器的“后退”按钮重试您的操作。”
}
}
}

通常,此错误是由缺少或过期的表单摘要引起的。如果您没有使用OAuth来授权您的请求,这些操作需要服务器的请求表单摘要值作为X-RequestDigest头的值

您可以通过向
http:///_api/contextinfo
。或者,如果您的代码在SharePoint页面中运行,则可以直接通过SharePoint控件“#uu REQUESTDIGEST”获取

"headers": {
    "X-RequestDigest": $('#__REQUESTDIGEST').val(),
    "accept": "application/json",
    "content-type": "application/json",
},

BR

修改标题以在SharePoint页面上包含X-RequestDigest

"headers": {
    "X-RequestDigest": $('#__REQUESTDIGEST').val(),
    "accept": "application/json",
    "content-type": "application/json",
},