Forum Discussion
Nagarajan_M
Dec 08, 2022Copper Contributor
SharePoint Online - Issue with REST API call on a List exceeded the threshold limit
I have a List in a SharePoint Online site collection which has exceeded 5000 items. I have indexed the columns that are needed in the REST API filter query during list creation itself. Below is t...
Dec 08, 2022
You need to use Pagingation to get more items that 5000. Here is a JS snippet that should do it for you
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Announcements')/items?$top=5000";
var response = response || []; // this variable is used for storing list items
function GetListItems(){
return $.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;
GetListItems();
}
$.each(response, function(index, item) {
arrayListItem[index] = item;
});
},
error: function(error){
}
});
}
- Nagarajan_MDec 10, 2022Copper ContributorNicolasKheirallah How does pagination help my issue. I have 5000 items that matches my query and am trying to fetch only 4999 using $top. But am getting only 4970 items