Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

403 forbidden error when trying to get list items (sharepoint)

$
0
0

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.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>