Question on using GraphServiceClient to get a list of subfolder/files given a known path https://mypersonalteamsite.sharepoint.com/IT/subfolder/subfloder1

Novian Winangun 1 Reputation point
2020-08-20T01:32:40.03+00:00

Hi,

I know that you can use HTTP request to get a list the children based on the Path:

GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{path-relative-to-root}:/children

But, how do you translate this to using GraphServiceClient on the server site using csharp?

For example, I am trying something like this:

var driveItems = await graphClient.Sites["mypersonalteamsite.sharepoint.com"].Drive.Root.{what else do I need to do specify the path?}.{Children?}.Request().GetAsync();

I know I have files and folders under https://mypersonalteamsite.sharepoint.com/IT I want to get these using path.

So if I need to get file in the subfolder I can just use the path. eg. https://mypersonalteamsite.sharepoint.com/IT/mysubfolder/mysubsubfolder2/file.txt

Also if I need to get list of files & folders, I just like to use the path eg. https://mypersonalteamsite.sharepoint.com/IT/mysubfolder/mysubsubfolder2/*

There is not enough documentation on how to use GraphServiceClient object.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,212 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amos Wu-MSFT 4,051 Reputation points
    2020-08-20T08:07:55.623+00:00

    You could use it like this:

    graphClient.Drives["driveid"].Root.ItemWithPath("/folder3").Children.Request().GetAsync().Result;  
    

    Test result:
    18990-result1.png
    19093-result2.png


    If the response is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments