0
votes

I have a SharePoint online site In which one folder is having more than 5000 records. The rest api is giving an error. The attempted operation is prohibited because it exceeds the list view threshold. If is use call - /_api/web/lists/getbytitle('Documents')/Items. this is working fine but I want the documents from one particular folder so for that I am using call - _api/web/GetFolderByServerRelativePath() which is giving error of threshold.

Is there any way to get folders data using title call of sharepoint online.

Note - title field is indexed in share point online.

1

1 Answers

0
votes

You can use GetFolderByServerRelativePath(). To avoid the limitation you can call 5000 items each time, until you get all data (recursively), using the d.__next property:

    var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('/folderName/innerFolder')/Files?$top=5000";
    var response = [];  // this variable is used for storing list items
 GetListItems();

function GetListItems(){
    $.ajax({
        url: url,  
        method: "GET",  
        headers: {  
            "Accept": "application/json; odata=verbose"  
        },
        success: function(data){
            response = response.concat(data.d.results);
            console.log(response);
            if (data.d.__next) {
                url = data.d.__next;
                GetListItems();
            }
            
        },
        error: function(error){
           console.log(error);
        }

    });
}