使用 .NET SDK 按路径获取 Microsoft Graph Drive 项目

Getting Microsoft Graph Drive items by path using the .NET SDK

因为它是 documented,使用 Microsoft Graph REST API 您可以(在其他选项中)通过 ID 或路径获取项目。正如预期的那样,这工作正常:

GET /me/drive/items/{item-id}/children
GET /me/drive/root:/{item-path}:/children

使用 .NET SDK,我可以通过 Id 获取文件夹(即第一种情况):

var items = await graphClient.Me.Drive.Items[myFolderId].Children.Request().GetAsync();

但是,我找不到如何(使用 .NET SDK)做同样的事情,而是指定路径而不是 Id(即第二种情况)。

我不想找到我已经知道的路径的 ID 来为其创建请求。对吗?

恐怕无法使用当前的 SDK(Microsoft Graph Client Library 1.1.1)执行此操作?

是这样的:

var items = await graphClient.Me.Drive.Root
                  .ItemWithPath("/this/is/the/path").Children.Request().GetAsync();

只使用普通路径。不要包含“:”,也不要包含“/drive/root:/”。

很明显,现在我看到了...

为了 Business/Sharepoint/Teams 将 Microsoft Graph SDK 与 Office365 一起使用,请将代码中的 "Me" 替换为 "Groups[teamId/groupId]"。

像这样:

var items = await graphClient.Groups["teamId/groupId"].Drive.Root
    .ItemWithPath("/this/is/the/path").Children.Request().GetAsync();

如果您使用 Microsoft Graph Explorer,您可以找到您的 Team/Group ID: https://developer.microsoft.com/en-us/graph/graph-explorer