The title states my problem quite exactly. If I try to gather all 400+ items from a list using sharepoint\'s REST API, I only get first 100.
I have read http://msdn.micro
You can use RowLimit & RowsPerPage in rest call. Below is the example
$.ajax({
url: siteurl + "/_api/web/lists/getbytitle('NewList')/items",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
RowLimit : null, //Specify the row limit
RowsPerPage : null, //Specify no of rows in a page
success: function (data) {
$('#oDataFilter').append("<table>");
$.each(data.d.results, function(index, item){
$('#oDataFilter').append("<tr><td class="+styleClass+">" + item.ID + "</td><td class="+styleClass+">"+ item.Title + "</td></tr>");
});
$('#oDataFilter').append("</table>");
},
error: function (error) {
alert('Error getListItems :: '+JSON.stringify(error));
}
The limitation is due to server side paging.
A workaround is to retrieve 100 items at a time, or override the limitation by entering a count of items:
https://$DOMAIN/$SITE/_api/web/Lists/getByTitle('$LIST')/Items?$top=1000
Note that there is also a threshold at 5000.
To anyone now seeing this, you can use data.d.__next
to get the next 100 items. Using some good old recursion, you can get all the items like so
function getItems(url) {
$.ajax({
url: url,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function(data) {
console.log(data);
// Do work
if (data.d.__next) {
getItems(data.d.__next);
}
},
error: function(jqxhr) {
alert(jqxhr.responseText);
}
});
}
Adding to Christophe's answer I would say listing all (potentially 5000) items in a list and parsing them would result in performance issues.
If you query sharepoint to show all items in a particular list it would only print out the first 100. But the xml response also provides the url to query for the next 100 list items.
At the very end of the xml response you will see a tag like this
<link rel="next" href="https://xxxxx.sharepoint.com/_api/web/lists/GetByTitle('list')/items?%24skiptoken=Paged%3dTRUE%26p_ID%3d100" />
The url inside href="...."
is what you'll need.
Querying the above would provide you with a list of the next 100 or less items.
If there are still more items left this xml response would in turn provide an other <link rel="next">
tag and if not this tag won't exist.
Better to handle 5000 items in sets of 100 rather than them all together in my opinion.