Click here to Skip to main content
15,881,757 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:

C#
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
Posted
Updated 13-Mar-23 4:06am

Solved by below code:

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

            foreach (var item in folders)
            {
                if(item.Folder!=null)
                {
                    comboBox1.Items.Add(item.Name);
                    oneDriveFolders.Add(item.Id, item.Name);
                }
            }
 
Share this answer
 
JavaScript
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