Get More than 5000 records from SharePoint list using Rest Api

How to Get More than 5000 records from SharePoint list using REST Api

You can use the below JS code to get more than 5000 records from SharePoint list using REST Api

JS Code:-


var response = response || [];
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Cable_Status')/items?$Select=ID,LOB&$top=1000";
$(document).ready(function() {
 GetListItems();  
});


function GetListItems(){
        return $.ajax({
            url: url,
            method: "GET",
            headers: {
                "Accept": "application/json; odata=verbose"
            },
            async: false,
            success: function(data){
                response = response.concat(data.d.results);
                if (data.d.__next) {
                    url = data.d.__next;
                    GetListItems();
                }
         
                var table = $("#MyTable");
                var html = "<thead><th>ID</th><th>LOB</th></tr></thead>";                 
$.each(response, function (key, value) {
                   html += "<tr><td>" + value.ID + "</td><td>" + value.LOB + "</td></tr>";         
    });
                table.html(html);
             
            },
            error: function(error){
              alert(JSON.stringify(error)); 
            }
        });
    } 
 

Comments

Popular posts from this blog

How to Customize exported excel's cell background color in Datatables

Populate dropdown using jquery ajax in SharePoint

Customizing SharePoint list and implementing Quick search using jQuery