sharepoint - 此页面的安全验证无效并且可能已损坏。请使用您的网络浏览器的返回按钮再次尝试您的操作

标签 sharepoint sharepoint-2013 webhooks sharepoint-rest-api

我正在尝试为共享点列表创建一个网络 Hook 。不幸的是,这样做的唯一方法是调用 API。所以我调用了 API 来创建我自己的 web Hook 到我的共享点站点中的自定义列表。

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

fetch("https://my-org.sharepoint.com/sites/my-site/_api/web/lists('list-id')/subscriptions", {
  "headers": {
    "accept": "application/json",
    "content-type": "application/json",
  },
  "body": "{\"resource\":\"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\"}",
  "method": "POST",
});

但它给出了 403 错误:

{
    "odata.error": {
        "code": "-2130575251, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again."
        }
    }
}

最佳答案

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

您可以通过向 http://<site url>/_api/contextinfo 发出带有空正文的 POST 请求来检索此值。 .或者,如果您的代码在 SharePoint 页面中运行,您可以直接通过 SharePoint 控件“#__REQUESTDIGEST”获取它。

BR

关于sharepoint - 此页面的安全验证无效并且可能已损坏。请使用您的网络浏览器的返回按钮再次尝试您的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64672169/

相关文章:

python - 如何在 Sharepoint 中更新文档的元数据? (Linux -> Web 服务 -> Sharepoint)

sharepoint - 如何测试单个前端 Web 服务器

javascript - 如何在 SharePoint 2013 JSOM 中设置 URL 字段的值

go - go中的dialogflow webhook

javascript - 在 firebase 上使用 Dialogflow Fulfillment Library v2 结束对话?

c# - 如何使用 Azure 代理 AD 和 ADAL 在 SharePoint On Prem 上进行身份验证?

sharepoint - 删除 PlaceHolderPageTitleInTitleArea 的内容

python - 如何修复在 Python 中使用 REST 连接到 SharePoint 并读取数据时的 JSON 解码器问题

javascript - 如何在完全信任的解决方案中通过 javascript 调用 Sharepoint 2013 API?

c# - 如何解决 "The WebHook verification request must contain a ' 代码的查询参数。”在 ASP.NET WebHook 接收器中?