Search code examples
c#oauth-2.0microsoft-graph-apionedrivemicrosoft-graph-files

Trying to get OneDrive Items using Microsoft Graph


I am trying to get my drive items from OneDrive by following the code snippets in Microsoft Graph Explorer. I am using the sample app provided by Microsoft's quick start (https://developer.microsoft.com/en-us/graph/quick-start)

this is the call I am reviewing:

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

var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Children.GetAsync();

The {drive-id} is straight forward but what is expected for {driveItem-id}?

In Graph Explorer I can use https://graph.microsoft.com/v1.0/me/drives in order to fetch my available drives (there is only 1) but there is only 1 relevant ID in my response.

Clarification would be appriciated

Thanks!


Solution

  • /drive/root is a shortcut for /drive/items/root so the driveItem-id can be replaced with root to make a call to get children in the root folder.

    var result = await graphClient.Drives["{drive-id}"].Items["root"].Children.GetAsync();