Microsoft Graph API - 驱动器的空根目录

Microsoft Graph API - Null Root for a Drive

我可以从我的个人驱动器中获取 Root,如下所示。

GraphServiceClient graphClient = new GraphServiceClient(myAuthProvider);
DriveItem folder = await graphClient.Drive.Root.Request().Expand(expandValue).GetAsync();

我可以按如下方式获取组并为每个组获取驱动器。

var groups = await graphClient.Groups.Request().GetAsync();
var drives = await graphClient.Groups[groups.First().Id].Drives.Request().GetAsync();

但是,当我为这些驱动器中的任何一个请求 Root 时,它始终为 Null。

DriveItem folder = drives.First().Root;

值得注意的是,云端硬盘本身看起来有效:名称、URL 和所有其他字段均有效。驱动器绝对不是空的。它包含许多文件夹和文件。我怎样才能从这个驱动器中获取项目?

Root 不是响应的一部分

var drives = await graphClient.Groups[groups.First().Id].Drives.Request().GetAsync();

使用 ExpandRoot 包含到响应中

var drives = await graphClient.Groups[groups.First().Id].Drives
                   .Request()
                   .Expand(x => x.Root).GetAsync();

var drives = await graphClient.Groups[groups.First().Id].Drives
                   .Request()
                   .Expand("root").GetAsync();