我想在UWP应用程序中列出我的所有业务项目的OneDrive。为此,我使用了来自NuGet的“微软图形客户端库”。它是Microsoft Graph REST-API的包装库。
当我试图从我的根驱动器或特定的文件夹ID中获取所有项或子项(我都尝试过了)时,我只得到一个空列表。但是在我的驱动器中有不同的文件和文件夹。即使我在没有这个包装器的情况下使用REST-API,我也只能得到一个空结果。
但是当我使用" recent“函数时,我会得到我最近使用过的物品的列表。
// Returns an empty result without error
GraphServiceClient.Me.Drive.Items.Request().GetAsync()
GraphServiceClient.Me.Drive.Root.Children.Request().GetAsync()
GraphServiceClient.Drives["id"].Items.Request().GetAsync()
// Returns all my recent used items
GraphServiceClient.Me.Drive.Recent().Request().GetAsync()
GraphServiceClient.Drives["id"].Recent().Request().GetAsync()
HTTP-Traffic如下所示:
GET https://graph.microsoft.com/v1.0/me/drive/root/children HTTP/1.1
SdkVersion: graph-dotnet-1.0.1
Cache-Control: no-store, no-cache
Authorization: Bearer 1234567890123456789
Host: graph.microsoft.com
Connection: Keep-Alive
// Response:
HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Server: Microsoft-IIS/8.5
request-id: 123456-7890123
client-request-id: 123456-7890123
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceB","ScaleUnit":"000","Host":"AGSFE_IN_3","ADSiteName":"AMS"}}
OData-Version: 4.0
Duration: 823.6454
X-Powered-By: ASP.NET
Date: Wed, 15 Jun 2016 06:56:29 GMT
8c
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('123456-7890123-456789')/drive/root/children","value":[]}
0
(我已经删除了Id,所以这不是问题)
有人能帮帮忙吗?
发布于 2016-06-14 06:28:07
要使用Microsoft Graph从OneDrive获取项,我们需要向端点发出请求。直到我们调用‘GetAsync’方法,‘request’方法才会发出真正的请求。
下面是一个获取默认驱动器的子项的示例:
var items = await graphserviceClient.Me.Drive.Root.Children.Request().GetAsync();
有关此SDK的更多详细信息,请参阅here。
https://stackoverflow.com/questions/37786970
复制