使用具有angular gives的RESTapi访问共享点列表403



我正在尝试调用sharepoint LIST REST API。我登录到sharepoint,当在浏览器中我键入类似

https://myserver.sharepoint.com/sites/mylist/_api/lists/getbytitle("OEC_Docs"(/项目

它按预期在浏览器中返回数据。然而,在我的angular 4应用程序中使用下面这样的代码会抛出403

getDocs(){
const httpOptions = {
headers: new HttpHeaders({
'Accept':  'application/json;odata=verbose',
'Content-Type': 'application/json'
})
};
return this.http.get(this.sharePointRestHost, httpOptions)
}

由于该应用程序在localhost上的同一浏览器中运行,所以我希望它能正常工作。请告知如何修复。

我已登录到sharepoint

是的,您已经登录,这就是为什么您可以在浏览器中看到结果

但你的angular应用程序很可能没有登录。这就是为什么它无法获得结果,并获得403(禁止(

尝试:

  1. 检查api文档,可能是他们在我们的应用程序发出请求时需要一些东西(cookie、头、会话(来授权它。

  2. 比较会话、cookie、本地存储在这两种情况下,我相信你会看到的不同

最新更新