I'm trying to get the recent list item via javascript from my sharepoint online server, but I only get a 403 forbidden error message.
My code sample to get all items:
function getItem() {
$.ajax({
url: site + "_api/web/lists/getbytitle('mysite')/items",
type: "GET",
contentType: "application/json;odata=verbose",
headers: {
"accept": "application/json;odata=verbose",
},
success: function(data) {
console.log("done");
},
error: function(err) {
console.log(JSON.stringify(err));
}
});
}
I've also tried to set the type to POST and add X-RequestDigest to the headers, but the same error appears.