我创建了一个Angular JS应用程序,它将在Share Point列表中输出数据列表。我正在尝试对我的共享点列表进行休息API调用以获取数据,但是我无法执行此操作,因为我收到错误403 Forbidden。
下面是我的控制器,它试图获取数据。
app.controller('RetrieveRecords', function ($q, $http, $scope) {
var url = "https://testapp.sharepoint.com/sites/testmyapplication/_api/web/lists/getByTitl
e('TestAppList')/items?$select=Status,Time";
$http(
{
method: "GET",
url: url,
headers: { "accept": "application/json;odata=verbose" }
}
).success(function (data, status, headers, config) {
$scope.details = data.d.results;
}).error(function (data, status, headers, config) {
});
});
我的Angular JS应用程序不是Share Point页面,我的应用程序基本上作为Azure静态网站托管。我检查了一些在线教程,但是我无法找到解决我面临的问题的方法。
谢谢。
@约翰,
您必须在标题中提供摘要。
您将在名为'__REQUESTDIGEST'的元素中找到必要的值。所以使用jQuery你可以获得如下值:$('#__ REQUESTDIGEST')。val()。
需要将此值添加到标头中:
headers: { "Accept": "application/json;odata=verbose", "X-RequestDigest": $('#__REQUESTDIGEST').val() }
你可以尝试添加这个标签,看看它是否有效。
希望能帮助到你。
MV