Sharepoint Office365 REST API在浏览器中不起作用

时间:2018-10-16 16:01:39

标签: javascript office365 sharepoint-online sharepoint-rest-api

我正在尝试从我们的Office365 Sharepoint网站(在 ourserver.sharepoint.com ),并在我正在开发的客户站点中使用它,该站点当前在本地主机上运行。

我已经从与Sharepoint的成功连接中提取了X-RequestDigest标头(使用Postman来模拟我要拨打的电话)。

我试图在HTML应用程序中运行的Javascript代码中包括的REST API调用看起来像这样:

$mightymouse.api.xhr("/_api/Lists/getbytitle('Event')/items", {
  type: "GET",
  dataType: "json",
  headers: {
    "accept": "application/json;odata=verbose",
    "X-RequestDigest": "0x7D5..."
  },
   xhrFields: {
     "withCredentials": false
  },
  crossDomain: true}).then( function okCallback(response)...

我在Chrome开发者工具中看到的响应是HTTP状态码403和以下响应:

{"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}

我试图使用Python模仿呼叫,但不同的是我可以使用Python发送的cookie(不能使用Javascript发送),尤其是FedAuthrtFa

0 个答案:

没有答案