列出子 API 不会提供驱动器/文件夹的所有子项 [英] List children API doesn't give all the children of the drive/folder

查看:23
本文介绍了列出子 API 不会提供驱动器/文件夹的所有子项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在获取用户 OneDrive 的文件/文件夹时遇到以下问题.

I am facing the following issue while getting files/folders for OneDrive of a user.

击球时

https://graph.microsoft.com/v1.0/users/{user-id}/驱动器

https://graph.microsoft.com/v1.0/users/{user-id}/drive

我在回复中得到了这个:

I get this in the response:

配额":{已删除":0,剩余":0,总计":0,使用":0}

表示驱动器未被使用或为空.

which denotes that the drive isn't being used or is empty.

击球时https://graph.microsoft.com/v1.0/users/{user-id}/drive/root我得到了回应 -

On hitting https://graph.microsoft.com/v1.0/users/{user-id}/drive/root I get the response -

"folder": {
    "childCount": 21
},
"root": {},
"size": 281236319

这里表示驱动器的根文件夹中有21个文件/文件夹,它们占用了281.23 MB的空间.

Here, it denotes that there are 21 files/folders in the drive's root folder and they occupy 281.23 MB of space.

现在,点击 https://graph.microsoft.com/v1.0/users/{user-id}/drive/root/children我在响应中得到空向量 -

Now, on hitting https://graph.microsoft.com/v1.0/users/{user-id}/drive/root/children I get empty vector in the response -

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('user-id')/drive/root/children",
"value": []

}

驱动器中存在文件.但我无法通过儿童 API 获得它们.任何帮助理解这 3 个不同的结果并获得响应将不胜感激

There are files present in the drive. But I am not able to get them via the children API. Any help in understanding these 3 different results and getting the response would be appreciated

谢谢.

推荐答案

这个问题是由于使用了错误的URL调用造成的.文档没有说得很清楚,但网址:

This issue is caused by calling the using the incorrect URL. The docs don't make it very clear but the URL:

https://graph.microsoft.com/v1.0/me/drive

如果驱动器"实际上是共享点实例的一部分,则不起作用.虽然 UI 在以用户身份登录时显示Drive",但 URL 包含对共享点的引用.

Does not work if the 'Drive' is actually part of a share point instance. Although the UI says "Drive" when logged in as the user, the URL contains reference to being share point.

正确使用的url其实是:

The correct url to use is actually:

https://{tenant}-my.sharepoint.com/_api/v2.0/drives/{drive id}/root/

https://{tenant}-my.sharepoint.com/_api/v2.0/drives/{drive id}/root/

这篇关于列出子 API 不会提供驱动器/文件夹的所有子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆