Hi @Navin Kumar S S ,
Thank you for posting in this community. You seem to have posted a duplicate thread, and that's okay. I will still provide an answer here as well.
I know what you're going through. This is a known issue with the SharePoint REST API.
It will throw an error if the query (or the first part of the filter query) returns more than 5000 items, even if you only use and return one item. $filter $top
This doesn't work even if you are indexing the column. If possible, try reducing the number of items returned in the first part of the query.
1.Here is a link on how to get by recursively calling:
2.In addition, you can retrieve more than 5,000 records from a SharePoint list using JavaScript and CAML queries. You need to use pagination. The following is an example of how to accomplish this:
To retrieve files from a SharePoint library containing more than 5,000 items using the REST API, you can implement the following strategies:https://learn.microsoft.com/en-us/answers/questions/1808639/how-to-retrieve-more-than-5k-records-from-a-sharep3.manage large libraries in SharePoint
Filter and Sort: Create filtered views that limit the number of items returned. By applying filters, you can ensure that the number of items returned does not exceed the list view threshold.
Use Folders: Organizing files into folders can help manage the number of items in a single view. By retrieving files from a specific folder, you can avoid hitting the list view threshold.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.