List children API doesn't give all the children of the drive/folder

江枫思渺然 提交于 2019-12-06 15:03:35

Once your user is authenticated and you retrieve an Access Token on behalf of that user. You would simply call this endpoint:

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

You may also want to look into a folder on that users OneDrive as well:

https://graph.microsoft.com/v1.0/me/drive/root:{/Folder-Path}:/children

Your URL is correct as well and should work as I just tested using my 'user-id' and was able to retrieve the files in my onedrive.

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

References:

https://stackoverflow.com/a/46614072/6559330 https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_list_children

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

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.

The correct url to use is actually:

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

You must use the scope Files.Read.All or Files.ReadWrite.All. In doing so, your requests to will no longer return an empty array.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!