简体   繁体   中英

SharePoint 2013 API jQuery.Ajax Access Denied

I am trying something simple - to retrieve list information from a SharePoint 2013 list. However, I am getting access denied when the jQuery Ajax is processed. I've tried setting up headers with the headers object and the beforeSend function, but with no success. Here is my jQuery.Ajax:

$.ajax({
        headers: { // also tried with Authentication
            "Authorization": someBasicCryptedCred,
            "Accept": "application/json; odata=verbose"
        },
        url: "http://spSiteCollection/_api/web/lists/getbytitle('MyList')/items",
        type: "GET",
        success: SuccessProcess,
        error: ErrorProcess
    });

My application is a simple MVC Mobile app

I am following these documentation (along with some other from MSDN but cannot post more than 2 links):

http://msdn.microsoft.com/en-us/library/jj870858.aspx http://msdn.microsoft.com/en-us/library/jj163228.aspx

Maybe you need the Form Digest Value, you can get with jQuery with

$('#__REQUESTDIGEST').val();

You can get with api rest call, with /_api/ContextInfo and that retrieve a JSON object with other many fields apart of Form Digest Value.

http://<site url>/_api/contextinfo

Regards

I don't see the Form Digest value in the call, could that be the reason?

X-RequestDigest = form digest value

Basically what you are doing, is looks like you are accessing cross site collection data from you app web, so please provide proper permission to your app through file. 文件为您的应用程序提供适当的权限。 thats it and you are done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM