Search code examples
restmicrosoft-graph-apionedrive

Microsoft Graph API - /drive/root/children always empty, even though I have files in my onedrive


I'm trying to use the Microsoft Graph API to List Children by Getting access without a user

I have built my URL as you would expect:

https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children

Where edffcd1c-e5b2-42f2-b554-XXXXXXXXX is the user ID of whom I'm trying to list the files.

Yet when I call this I get an empty result every time:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drive/root/children",
    "value": []
}

Why is that?

UPDATE: It seems that this API is only returning files from the Sharepoint account... not the OneDrive account. I already have access to the Sharepoint files from the Sharepoint API's themselves. Is there a way to get OneDrive files from the Microsoft Graph API?

This URL https://dev.onedrive.com/README.htm seems to state that we should be able to do this.


Solution

  • I just had a typo in the User:

    https://graph.microsoft.com/v1.0/edffcd1c-e5b2-42f2-b554-XXXXXXXXX/drive/root/children

    was supposed to be

    https://graph.microsoft.com/v1.0/users('edffcd1c-e5b2-42f2-b554-XXXXXXXXX')/drive/root/children