question

kelly-7927 avatar image
0 Votes"
kelly-7927 asked saldana-msft edited

Get all the files and folders in the library of SharePoint Online site with one request

I am getting the files of a folder using this: https://docs.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http. This works fine for me.

But the endpoint can only get the files in the first level, it cannot get the files in the subfolders. I need to loop through all the folders to get the files, this is not an option.

My library is like this: foler ->subfolder ->sub subfolder ->files. All the folders have files and subfolders. I just want to get all the files using one request. Is it possible?

Kelly

sharepoint-devmicrosoft-graph-files
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered

Hi @kelly-7927,

As a workaround, you could get all the list items in the library using this endpoint:

 https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=driveItem

In the response, it would contaion all the files and folders in the specifice library.



If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.