我试图通过 Microsoft Graph Api (SDK) 获取驱动器的项目并尝试了以下选项:
_graphServiceClient.Drives[driveInfo.Id].Items.Request().GetAsync()
:,不幸的是,这会导致消息错误 消息错误“请求格式错误或不正确”和代码“无效的请求”。如果我执行_graphServiceClient.Drives[driveInfo.Id].Request().GetAsync()
但是,我取回了除Items
财产是null
.
_graphServiceClient.Drives[driveInfo.Id].Request().Expand(d => d.Items).GetAsync()
,这也会导致消息错误“请求格式错误或不正确”和代码“无效的请求”.
我不知道如何从这里继续,仍在研究,但文档目前让我一无所知。任何人都可以成功.Expand()
或从云端硬盘获取实际文件?
谢谢,
是
你只使用Items
当你获取单个DriveItem
:
await graphClient
.Me
.Drive
.Items[item.Id]
.Request()
.GetAsync();
await graphClient
.Drives[drive.Id]
.Items[item.Id]
.Request()
.GetAsync();
当你想检索一个DriveItem
集合,需要指定根文件夹:
await graphClient
.Me
.Drive
.Root // <-- this is the root of the drive itself
.Children // <-- this is the DriveItem collection
.Request()
.GetAsync();
await graphClient
.Drives[drive.Id]
.Root
.Children
.Request()
.GetAsync();
SDK 单元测试是快速示例的良好来源。例如,OneDriveTests.cs https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneDriveTests.cs包含几个用于寻址 Drives 和 DriveItems 的示例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)