繁体   English   中英

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

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

文档所述 ,使用Microsoft Graph REST API,您可以(除其他选项外)通过Id或Path获取项目。 可以正常工作,如预期的那样:

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:/”。

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

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

像这样:

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

如果您使用Microsoft Graph Explorer,则可以找到您的团队/组ID: https : //developer.microsoft.com/zh-cn/graph/graph-explorer

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM