感谢您接触我的问题。我正在使用SharePoint开发cordova应用程序。当我尝试获取或创建列表项时,我收到错误System.UnauthorizedAccessException
。我被困在这里两天了。我不明白什么是错的。
错误:
System.UnauthorizedAccessException
error code: 2147024891
Access denied. You do not have permission to perform this action or access this resource.
Status:403
Status Text:forbidden.
我创建列表项的代码:
createList: function(accessTokens,digestValues){
alert("creating list item");
var sendItem = {"Title": "Created Title","Age":"27","__metadata": {"type": "SP.Data.WebServiceTestListItem"}};
alert(digestValues);
$.ajax({
url: "https://mytenant.sharepoint.com/MyProject/_api/web/lists/getbytitle('WebServiceTest')/items",
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(sendItem),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": digestValues,
"X-HTTP-Method": "PUT",
"If-Match": "*"
},
success: function (data) {
alert("Update Successful");
},
error: function (msg) {
alert("fail"+msg);
alert("fail2:"+JSON.stringify(msg));
$("#userlist").text(JSON.stringify(msg));
}
});
},