[ad_1]
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.
私が試したこと:
グラフAPIを使用してすべてのファイルを取得しようとしました
解決策 1
以下のコードで解決:
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); } }
解決策 2
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);
[ad_2]
コメント