1

I have an app that contains a few lists within its own app web. I need to add new items thru the REST Api. The problem is when I try to add an item I get a

403 Forbidden error

Which is odd because I thought the app had full control over its own app web. Please advise.

AJAX

var def = new jQuery.Deferred();            

var executor = new SP.RequestExecutor(_spPageContextInfo.siteAbsoluteUrl);
var data = { __metadata: { type: 'SP.Data.ProductsListItem' } };
data = jQuery.extend({}, data, product);
data = JSON.stringify(data);

console.log('Product Request Body: \n' + data);

executor.executeAsync({
    url: urlBase + "/_api/web/lists/getbytitle('Products')/items",
    method: "POST",
    body: data,
    headers: {
        "accept": "application/json;odata=verbose",
        "content-type": "application/json;odata=verbose",
        "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
    },
    success: function (results) {
        def.resolve(results);
    },
    error: function (results) {
        def.reject(results);
    }
});

return def.promise();

Error

It looks like the request isn't going to the proper web? But I'm setting the context to _spPageContextInfo.webAbsoluteUrl, which gives me the correct URL I want.

Network Panel Output

Permissions

There aren't any permission bc I thought apps OOB had Full Control of the app web???

Permissions Tab

5
  • 1
    What permission you have provided for the app? Check the Permission tab Oct 28, 2014 at 14:48
  • Updated with permission tab. I haven't set any but that's bc I thought the app had full control of the app web. That's where the list is. Oct 28, 2014 at 14:54
  • Try to give Full Permission Oct 28, 2014 at 14:59
  • I was setting the SP.RequestExecutor to the Site context instead of the Web... Thanks for your help. Oct 28, 2014 at 15:05
  • @ExceptionLimeCat Just to confirm, you resolved this issue? If so, can you post an answer detailing your resolution?
    – wjervis
    Oct 28, 2014 at 15:31

1 Answer 1

1

My issue was caused by setting my SP.RequestExecutor context to the site collection instead of the App Web.

 var executor = new SP.RequestExecutor(_spPageContextInfo.webAbsoluteUrl);

Thanks for everyone's help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.