Forum Discussion
marwan2395
Feb 26, 2025Copper Contributor
how to get files of a specific folder path in sharepoint using /lists graphapi
i was able to get folders of a specific folder path using /drives but in /lists it will return files also not just folders unlike /drives , i already made a python script to retrieve files from docum...
grant_jenkins
Apr 14, 2025Iron Contributor
Not sure if this will get what you're after, but you could try the search endpoint.
https://graph.microsoft.com/v1.0/search/query
And in the Request Body
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "path:https://YOUR_TENANT.sharepoint.com/sites/YOUR_SITE/LIBRARY/FOLDER1/FOLDER2"
},
"fields": [
"id",
"title",
"createdBy",
"createdDateTime",
"lastModifiedBy",
"lastModifiedDateTime",
"webUrl",
"contentType"
]
}
]
}One caveat though is that search will only return the last published version of a document depending on the library settings.
If you just wanted to return files (and not folders) you could add IsDocument:True to your query string.
"queryString": "path:https://YOUR_TENANT.sharepoint.com/sites/YOUR_SITE/LIBRARY/FOLDER1/FOLDER2 AND IsDocument:True"
I'm not sure if we can filter with /list/GUID/items as you are after.