How to get folders and files separately using graph drives API ?

Yumihiko Tsuzuki 41 Reputation points
2021-10-20T07:57:54.1+00:00

I understand that the /children endpoint does not support the $filter parameter.
htps://learn.microsoft.com/en-us/answers/questions/501232/microsoft-graph-drive-filter-children-folder-file.html

Is there any way to get folder and file separately ?
From the application's performance point of view, it is crucial that we can get only files excluding folders.

It is possible to get only folder like this (but not supported).
GET https://graph.microsoft.com/v1.0/drives/{drive ID}/root:{folder path}:/children?filter=folder%20ne%20null

Getting file only doesn't work.
GET https://graph.microsoft.com/v1.0/drives/{drive ID}/root:{folder path}:/children?filter=file%20ne%20null

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

Accepted answer
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-10-21T03:02:28.147+00:00

    Hi @Yumihiko Tsuzuki ,

    Per my research, currently we cannot getting folders and files separately under a folder using Graph API.

    You could submit the feature request in Microsoft 365 Developer Platform. They may take this into consideration.


    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.



1 additional answer

Sort by: Most helpful
  1. KYCDD 1 Reputation point
    2022-08-10T13:46:22.127+00:00

    Has there been an update to this? Are we now able to filter on folder v file? Thanks.

    0 comments No comments