Click here to Skip to main content
15,746,813 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to fetch all the folders in Onedrive(not files) using graph api. I am looking for query similar to the below query:

var folders=await client.Me.Drive.Root.Children.Request().GetAsync();

The above query fetches both files and folders and I am looking for folders only.
Thanks in advance.

What I have tried:

tried fetching all files using graph api
Updated 13-Mar-23 4:06am

Solved by below code:

var folders = await client.Me.Drive.Root.Children.Request().GetAsync();

            foreach (var item in folders)
                    oneDriveFolders.Add(item.Id, item.Name);
Share this answer
const searchResponse = {
      requests: [
          entityTypes: ['driveItem'],
          query: { queryString: `isDocument=false` },
          from: 0,
          size: 200,
          fields: [`id`, `name`, `parentReference`],
    const search = await client.api('/search/query').post(searchResponse);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900