SharePoint Rest API SPQueryThrottledException

Neelkumar Maheta (nmaheta) 30 Reputation points
2024-12-03T09:36:53.5133333+00:00

Hello Team,

We're using SharePoint 2019 On-Premises instance. We have one document library containing more than 10000 items. We have threshold limit for list/library as 5000 (the default one).

we are tring to access folder having just 200 items from that library via SharePoint Rest API. These are the ways we're trying to access items within specified folder.

  1. api/web/lists/getbytitle('Libraryname')/items?$filter=FileDirRef eq 'Folder relative path'&$top=200
  2. api/web/lists/getbytitle('Libraryname')/items?$filter=FileDirRef eq 'Folder relative path'

Both above API returns following response.
{ "odata.error": { "code": "-2147024860, Microsoft.SharePoint.SPQueryThrottledException", "message": { "lang": "en-US", "value": "The attempted operation is prohibited because it exceeds the list view threshold." } } }

We would like to understand why API is saying the operation exceeds the list view threshold. As we've threshold limit for list is 5000 and folder is having just 200 items.

Thank you.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,154 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 37,151 Reputation points Microsoft Vendor
    2024-12-04T02:25:52.69+00:00

    Hi @Neelkumar Maheta (nmaheta) ,

    You can not fetch the List items more than threshold limit. You may think only 200 items which meets your filter. But before getting the filter result, the api will need to get all of the 10000 items first. This is the reason why you get exceed threshold limit exception.

    As a workarond, you will need to apply indexing on columns you are using in filtering and sorting: Add an index to a list or library column.

    And here is similar issue with yours for reference

    1. Filtering large list (more than 5K items) using two columns with REST API
    2. Manage large lists and libraries

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.