I'm creating a travel app in sharepoint 2013 (sharepoint-hosted app) from visual studio and deploying it on office 365. I have created a custom list on office 365 and am trying to access it on office 365 from jquery ajax with the following code
but I get system.unauthorizedAccessException you do not have permission to perform this action
this is my code
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
var listName = "TestList";
$.ajax(
{
url: siteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function (data) {
alert("Success");
},
error: function (err) {
alert(JSON.stringify(err));
}
}
);