We are facing some problems dealing with large list on SharePoint online via API, we tried below methods but no luck, please advise if there is a proper way to handle such cases.


  • Pagination
  • Sorting – single column asc / desc
  • Filtering – multiple columns filtering, the first filter does not guarantee the result would be limited within 5000 records

Method 1: Sharepoint List API - REST

Problem: It throws Microsoft.SharePoint.SPQueryThrottledException when the first filter condition return more than 5000 records

We have tried indexing the columns but still we couldn't guarantee it is processing less than 5000 records and it will still fail on some filter conditions and order by condition

await sp.web.lists
        .filter('FILTER QUERIES HERE')
        .orderBy('fieldName', true)

Method 2:

a) Sharepoint RenderListDataAsStream API - REST in CAML via PnP

Problem: When it has filter and order by descending, then it will return zero result. Noticed that Sharepoint UI is calling SP.FavoriteLists.GetListsBy API when a list is ordered by descending

await sp.web.lists.getByTitle(TABLE).renderListDataAsStream({
      ViewXml: `<View><Query><OrderBy><FieldRef Name='fieldName' Ascending='FALSE'/></OrderBy>
      <Where><Eq><FieldRef Name="fieldName" /><Value Type="Number">1</Value></Eq></Where></Query>
      <ViewFields><FieldRef Name='ID'/><FieldRef Name='Title'/></ViewFields>
      <RowLimit Paged='TRUE'>100</RowLimit></View>`,

b) Sharepoint RenderListDataAsStream API - REST in query params via axios.post

Problem: Same as above and even have to mix the use of CAML if we need to select fields or filter column by free text such as checking string with ‘contains’

await axios.post(
        parameters: {
          AddRequiredFields: true,

1 Answer 1


I was looking for a solution to solve a similar requirement, and found a JQUERY solution as to how to call REST API recursively at here

I was able to retrieve all IDs from a list that has 12K items. I've added a Web Part Page in SPO and added a Content Editor and link to a text file containing the HTML and JQUERY. I've not noticed any issues retrieving 12K IDs recursively. Please note that I used $top=1000 in the REST API call

Please refer to the code and screenshot below.


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('MyLibrary')/items?$select=ID&$top=1000";
var response = response || [];  // this variable is used for storing list items

    function GetListItems(){
            url: url,  
            method: "GET",  
            headers: {  
                "Accept": "application/json; odata=verbose"  
            success: function(data){

             //response = response.concat(data.d.results);//Not used here
             data.d.results.forEach(function(item){  //print out the ID

            $("#divData").append(item.ID + "|");



              //Calling API Recursively 
                if (data.d.__next) {                    
                    url = data.d.__next;
            error: function(error){
                   // error handler code goes here
        alert("Error Retrieving Data");






<h1>More than 5K Items</h1>

<div id="divData">
 <p>Data will be copied here</p>



  • if you don't use filter they it would work but the problem is when you try to use filter and sorting where filtered result set has more than 5000 items.
    – Bhavesh
    Apr 26 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.