Microsoft Graph API - /drive/root/children 始终为空,即使我的 onedrive 中有文件
Microsoft Graph API - /drive/root/children always empty, even though I have files in my onedrive
我正在尝试使用 Microsoft Graph API 来 List Children by Getting access without a user
我已经构建了我的 URL,正如您所期望的那样:
https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children
其中 edffcd1c-e5b2-42f2-b554-XXXXXXXXX
是我要列出文件的用户 ID。
然而,当我调用它时,我每次都得到一个空结果:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drive/root/children",
"value": []
}
这是为什么?
更新:这 API 似乎只从 Sharepoint 帐户返回文件...而不是 OneDrive 帐户。我已经可以从 Sharepoint API 本身访问 Sharepoint 文件。有没有办法从 Microsoft Graph API 获取 OneDrive 文件?
这个URLhttps://dev.onedrive.com/README.htm似乎表明我们应该能够做到这一点。
我刚刚在用户中输入错误:
https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children
应该是
https://graph.microsoft.com/v1.0/users('edffcd1c-e5b2-42f2-b554-XXXXXXXXX')/drive/root/children
您也可以使用这个端点
https://graph.microsoft.com/v1.0/me/drive/root/children
并通过授权header Bearer Token
Is there a way to get OneDrive files from the Microsoft Graph API?
是的,有:您必须使用范围 Files.Read.All
或 Files.ReadWrite.All
然后,您对 /drive/root/children
的请求将不再是 return 空数组。
有两件事:
1) 首先检查用户是否给了
的权限
Files.Read.All or Files.ReadWrite.All
2) 以下端点不适用于企业帐户
/drive/root/children
我改成了
/drives/{drive_id}/root/children
而且效果很好。请检查。
我正在尝试使用 Microsoft Graph API 来 List Children by Getting access without a user
我已经构建了我的 URL,正如您所期望的那样:
https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children
其中 edffcd1c-e5b2-42f2-b554-XXXXXXXXX
是我要列出文件的用户 ID。
然而,当我调用它时,我每次都得到一个空结果:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drive/root/children",
"value": []
}
这是为什么?
更新:这 API 似乎只从 Sharepoint 帐户返回文件...而不是 OneDrive 帐户。我已经可以从 Sharepoint API 本身访问 Sharepoint 文件。有没有办法从 Microsoft Graph API 获取 OneDrive 文件?
这个URLhttps://dev.onedrive.com/README.htm似乎表明我们应该能够做到这一点。
我刚刚在用户中输入错误:
https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children
应该是
https://graph.microsoft.com/v1.0/users('edffcd1c-e5b2-42f2-b554-XXXXXXXXX')/drive/root/children
您也可以使用这个端点 https://graph.microsoft.com/v1.0/me/drive/root/children
并通过授权header Bearer Token
Is there a way to get OneDrive files from the Microsoft Graph API?
是的,有:您必须使用范围 Files.Read.All
或 Files.ReadWrite.All
然后,您对 /drive/root/children
的请求将不再是 return 空数组。
有两件事:
1) 首先检查用户是否给了
的权限Files.Read.All or Files.ReadWrite.All
2) 以下端点不适用于企业帐户
/drive/root/children
我改成了
/drives/{drive_id}/root/children
而且效果很好。请检查。