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.
Permissions
There aren't any permission bc I thought apps OOB had Full Control of the app web???
SP.RequestExecutor
to the Site context instead of the Web... Thanks for your help.