2
votes

I created two lists in my SharePoint 2010 site. one has 10 items other has 10000 items.

On the small list I can say

http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/SmallList?$top=1&$skip=1

no problem it works perfect.

when I say

http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList?$top=1&$skip=1

it throws an error "An error occurred while processing this request"

The internet is full of confustion because most blogs/articles etc talk about "SP2013" where I guess there is a __next in the body of XML which you get from SP.

However I am using SP2010 and this is a PURE client side solution with NO server side object model at all.

Can anyone tell me how to paginate through large lists "specifically" on SP2010.

Please post some working URLs with rest commands.... which you have tested against a large list (please let me know if you need me to provide code which will create a large list of 10K items for you).

2
Works on my large list (50k items) SP2010 SP2. Perhaps you're hitting some list throttling problem (default view sorted on a non-indexed column). It may help to look at the error in the ULS log.ErikE
Did you find the solution for this? I'm asking you this cos I see neither of the answers are upvoted.The Godfather

2 Answers

1
votes

You could do it using JavaScript and the WebServices. With the JavaScript API library I created, called SharepointPlus, you'll have to do that (with version 3.0.7):

$SP().list("Name of your list").get({fields:"ID,Title",rowlimit:5000,paging:true},function(data) {
  console.log(data.length)
})

You'll have all the items into the 'data' array. You can go thru the array and stop when you reach X elements in a JavaScript loop for example. Like that you should not have an error message due to the large size of your list.

1
votes

$skip query option is not supported, but $top is.

Workaround, use a mix of $orderby on ID, $filter on ID and $top x items, and loop.

Your query becomes http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt {lastId}&$top=100

{lastId}=0 on the first run.

Loop the items found, keep track of the "Last Id" and pass it to the next query.

http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt 0&$top=100

http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt 123&$top=100

http://mysharepoint.com/sites/testsite/_vti_bin/listdata.svc/LargeList()?$orderby=Id&$filter=Id gt 345&$top=100

repeat.

Note 1: ID is a column that is always indexed, other

Note 2: This pattern also works with the REST API (LINQ query)