2

I am fetching data from a list using REST call. I have added filter query in the REST url also the the column on which filter operation id done is set as Indexed column in the list. The no of items returned is more than 5000, so it is throwing threshold/throttling error. is there any solution to overcome this apart from increasing the threshold value from CA.

Thanks.

1 Answer 1

0

You can use in built SP Rest api paging. First limit the result = using top key then you can page using data.d.__next key . Sample snippet

function getReport() {
    $.ajax({
        url: queryUrl,
        method: "GET",
        headers: {
            "accept": "application/json; odata=verbose"
        },
        success: function(data) {
            try {
                $(data.d.results).each(function(index) {
                   //process your logic
                });
                //Pagging
                if (data.d.__next) {
                    queryUrl = data.d.__next;
                    getReport();
                } else {                
                 //last page       
                }
            } catch (err2) {                 
                console.log(JSON.stringify(err2));
            }
        },
        error: function(jQxhr, errorCode, errorThrown) {            
            console.log(errorThrown);
        }
    });
}

hope it helps

3
  • ok...so if i put top=500 and assume filtered data is 5000, then it will iterate for 10 times and give me all 5000 data...is it like that..plz explain.
    – rupesh roy
    Aug 11, 2016 at 13:44
  • yeah , it will fetch
    – Ravindra
    Aug 12, 2016 at 5:26
  • 1
    Incorrect: if you use $top=500, it will only return the first 500 results and will not have the __next variable there.
    – user56339
    Nov 22, 2016 at 6:18

Your Answer

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

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