How to control the Response from Sharepoint API "GET /sites/{siteId}/drives".

Takamoto Ide 40 Reputation points
2025-01-27T11:00:01.54+00:00

I am using the API endpoint "GET /sites/{siteId}/drives" to retrieve a list of libraries.

I use the query, "top", but the response does not return the expected number of items.

For example, if there are 8 document libraries and I specify $top=10, the response only returns 5 items.

I have three questions:

1. Why does the response from "/sites/{siteId}/drives" not match the specified "top" value?

2. Are there any ways to prevent the issue described in question 1?

3. Is there an upper limit for the "top" value??

Thank you for your assistance.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,959 questions
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,251 questions
0 comments No comments
{count} votes

Accepted answer
  1. Chiara Carbone 80 Reputation points
    2025-01-27T12:52:02.24+00:00

    Hi

    The discrepancy arises because the /sites/{siteId}/drives endpoint does not return system libraries, even though they exist. The Microsoft Graph API filters out libraries such as:

    • Site Assets
    • Other system-generated libraries

    Even if $top is set higher than the number of user-created libraries, the system will not include system drives in the response unless explicitly.

    You can try to include system to include system libraries: /sites/{siteId}/drives?$select=id,name,system&top=5

    Then the accurate number of items is returned.

    Reference: https://learn.microsoft.com/en-us/graph/api/drive-list?view=graph-rest-1.0&tabs=http#remarks

    1 person found this answer helpful.

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.