SharePoint REST Get all items __next

When a REST query is run against a SharePoint list, not all items are returned if it contains more than 100 items. The default server paging is 100.

It is a good practice to check the __next property of the JSON results to make sure all items are returned.

Below is a code snippet running from a SharePoint hosted add-in.

var url = appUrl + "/_api/SP.AppContextSite(@target)/Web/Lists/getByTitle('Repairs')/Items?$select=Title&@target='" + hostUrl + "'";
jQuery.getScript(scriptbase + "SP.RequestExecutor.js", getRepairDetails);

function getRepairDetails() {
var executor = new SP.RequestExecutor(appUrl);
url: url,
method: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
success: function (data) {
var response = JSON.parse(data.body);
message.append(String.format("Retrieved {0} items", response.d.results.length));

if (response.d.__next) {
url = response.d.__next;
error: function (data, errorCode, errorMessage) {


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s