Forum Discussion
SharePoint REST API: How to retrieve all folders in a list?
- Dec 07, 2018
Hi imbourg
You can filter by content type for example.
/_api/web/lists/GetByTitle('Documents')/items?$filter=ContentType eq 'Folder'
From here you can then select and expand other properties to return what you need.
Hope this helps
Thank you Joel Rodrigues
I also found this:
/_api/web/lists/GetById('${ListID}')/Items?$filter=FSObjType eq 1But the problem is that just like yours, the response does not give the folders' names.
Then I found:
/_api/web/lists/GetById('${ListID}')/rootFolder/FoldersIt gives the folders' name but curiously it finds an additional folder named Item :(
Even with a list without folders, it will list that weird folder...
Thanks very much
Using FSSobjType is another valid way of doing it.
Having to access the /Folders endpoint is what I meant with selecting and expanding the required properties. You have multiple properties you can select/expand to get all the information you need as they may be split across different endpoints.
Glad it's working for you :)
Sorry the delay in replying back. Swapped phone and had issues with MFA...
Joel