Question

Created a page in which I have added a drop-down box . The drop-down box fetches all the ID's of a list .

I am fetching the ID by using REST API . In the endpoint url I have added $top = 1000 to return only the top 1000 item IDs.

But the drop-down list only shows the item IDs till 2000. But I am having 2015 items in the list.

Is there any other way to achieve this?

I want the top 1000 ID's to be displayed in the drop-down box.

No correct solution

OTHER TIPS

this may be because the "top=1000" attribute will retrieve only the 1st 1000 items mostly based on other filters you might have applied. if the "ID=2000" is the 1000th item then it will show the item with the ID=2000 as the last item. there are two options you may want to try.

  • Increase the retrieval limit example, top=1015
  • Try to use Sort "&$orderby=Id desc"

Hope one of the above method provides you the required result.

If you want the latest created items IDs, Sort list items in descending order while fetching the list items using REST api. Use orderby clause like given below:

siteUrl/_api/web/lists/getbytitle('ListName')/items?$select=Title,ID&$orderby=ID desc&$top=1000

References:

  1. Use OData query operations in SharePoint REST requests.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top