Solution to use Recursive call to retrieve more than 5000 items in SharePoint REST API
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('DocumentList')/items?$top=1000";
//By default REST API retrieve 100 items. By using top we can retrieve up to 5000 items
var response = response || []; // this variable is used for storing list items
function GetListItems(){
$.ajax({
url: url,
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
success: function(data){
response = response.concat(data.d.results);
if (data.d.__next) {
url = data.d.__next; // to get the next set of items
GetListItems();//Recursive function
}
},
error: function(error){
}
});
}
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('DocumentList')/items?$top=1000";
//By default REST API retrieve 100 items. By using top we can retrieve up to 5000 items
var response = response || []; // this variable is used for storing list items
function GetListItems(){
$.ajax({
url: url,
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
success: function(data){
response = response.concat(data.d.results);
if (data.d.__next) {
url = data.d.__next; // to get the next set of items
GetListItems();//Recursive function
}
},
error: function(error){
}
});
}
Comments
Post a Comment