Search code examples
c#microsoft-graph-apimicrosoft-graph-sdksmicrosoft-graph-files

List files in a SharePoint/teams site root missing


Using c# SDK Microsoft.Graph 5.71.0

I have my _graphClient I am trying to list files in a sharepoint site. so far I have

var driveItemsb = await _graphClient.Sites[_siteId].Drive.Root.Children.Request().GetAsync();

documentation appear to be calling for "Root" however SDK does not recognise it.

What would be the proper way to do this?


Solution

  • The SDK doesn't generate code for all endpoints. You need to make 2 calls. First call to get drive id and the second call to get children of the root.

    var drive = await _graphClient.Sites[_siteId].Drive.GetAsync();
    var rootChildren = await _graphClient.Drives[drive.Id].Items["root"].Children.GetAsync();