System.UnauthorizedAccessException cordova

时间:2016-05-27 07:58:17

标签: javascript jquery ajax cordova sharepoint

感谢您接触我的问题。我正在使用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.

这是错误截图: enter image description here

我创建列表项的代码:

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));

    }
});
},

0 个答案:

没有答案
相关问题