Kiril Iliev
Kiril Iliev

Reputation: 1

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

Upvotes: 0

Views: 3039

Answers (3)

rubentnf
rubentnf

Reputation: 11

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

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

You can get it 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

Upvotes: 1

Rishi Jagati
Rishi Jagati

Reputation: 626

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 "AppManifest.xml" file. thats it and you are done.

Upvotes: 0

user2225566
user2225566

Reputation: 1

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

X-RequestDigest = form digest value

Upvotes: 0

Related Questions