SOLVED

SharePoint REST API: How to retrieve all folders in a list?

%3CLINGO-SUB%20id%3D%22lingo-sub-296914%22%20slang%3D%22en-US%22%3ESharePoint%20REST%20API%3A%20How%20to%20retrieve%20all%20folders%20in%20a%20list%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-296914%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20All%2C%3C%2FP%3E%3CP%3EDoes%20SharePoint%20allow%20to%20retrieve%20all%20folders%20in%20a%20List%3F%20(Not%20a%20Doc%20Library).%20Just%20a%20basic%20List.%3C%2FP%3E%3CP%3EI%20am%20using%20SharePoint%20Online.%3C%2FP%3E%3CP%3EI%20tried%26nbsp%3B%3CSTRONG%3E%2F_api%2Fweb%2Flists%2FGetById('%24%7BListID%7D%3C%2FSTRONG%3E%3CSPAN%3E%3CSTRONG%3E')%2FFolders%3C%2FSTRONG%3E%20without%20luck.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EAnd%20please%20can%20someone%20share%20a%20link%20to%20a%20comprehensive%20SPO%20Lists%20%26amp%3B%20Doc%20Lib%20REST%20API%20reference%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20only%20have%20this%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fjj860569.aspx%23Reference%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fjj860569.aspx%23Reference%3C%2FA%3E%20.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EIs%20it%20not%20outdated%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-298259%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%3A%20How%20to%20retrieve%20all%20folders%20in%20a%20list%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-298259%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247174%22%20target%3D%22_blank%22%3E%40imbourg%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20FSSobjType%20is%20another%20valid%20way%20of%20doing%20it.%3C%2FP%3E%3CP%3EHaving%20to%20access%20the%20%2FFolders%20endpoint%20is%20what%20I%20meant%20with%20selecting%20and%20expanding%20the%20required%20properties.%20You%20have%26nbsp%3Bmultiple%20properties%20you%20can%20select%2Fexpand%20to%20get%20all%20the%20information%20you%20need%20as%20they%20may%20be%20split%20across%20different%20endpoints.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGlad%20it's%20working%20for%20you%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3ESorry%20the%20delay%20in%20replying%20back.%20Swapped%20phone%20and%20had%20issues%20with%20MFA...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJoel%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-297322%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%3A%20How%20to%20retrieve%20all%20folders%20in%20a%20list%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-297322%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9907%22%20target%3D%22_blank%22%3E%40Joel%20Rodrigues%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20found%20this%3A%26nbsp%3B%3C%2FP%3E%3CPRE%3E%2F_api%2Fweb%2Flists%2FGetById('%24%7BListID%7D')%2FItems%3F%24filter%3DFSObjType%20eq%201%3C%2FPRE%3E%3CP%3EBut%20the%20problem%20is%20that%20just%20like%20yours%2C%20the%20response%20does%20not%20give%20the%20folders'%20names.%3C%2FP%3E%3CP%3EThen%20I%20found%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%2F_api%2Fweb%2Flists%2FGetById('%24%7BListID%7D')%2FrootFolder%2FFolders%3C%2FPRE%3E%3CP%3EIt%20gives%20the%20folders'%20name%20but%20curiously%20it%20finds%20an%20additional%20folder%20named%20%3CSTRONG%3EItem%26nbsp%3B%3C%2FSTRONG%3E%3A(%3C%2Fimg%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEven%20with%20a%20list%20without%20folders%2C%20it%20will%20list%20that%20weird%20folder...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20very%20much%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-297277%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%3A%20How%20to%20retrieve%20all%20folders%20in%20a%20list%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-297277%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247174%22%20target%3D%22_blank%22%3E%40imbourg%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20filter%20by%20content%20type%20for%20example.%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22pln%22%3E%2F_api%2Fweb%2Flists%2FGetByTitle('Documents')%2Fitems%3F%24filter%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EContentType%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20eq%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22str%22%3E'Folder'%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3EFrom%20here%20you%20can%20then%20select%20and%20expand%20other%20properties%20to%20return%20what%20you%20need.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1405924%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20REST%20API%3A%20How%20to%20retrieve%20all%20folders%20in%20a%20list%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1405924%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9907%22%20target%3D%22_blank%22%3E%40Joel%20Rodrigues%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20endpoint%20isolated%20the%20folders%20in%20the%20list%20for%20me%2C%20thank%20you.%26nbsp%3B%20I%20have%20a%20question%20that%20maybe%20you%20can%20help%20me%20with.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20writing%20an%20android%20app%20to%20consume%20the%20API%20data%20and%20finding%20that%20the%20Title%20in%20the%20json%20object%20is%20returning%20null%3A%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%22Title%22%3C%2FSPAN%3E%3CSPAN%3E%3A%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Enull%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EI%20am%20not%20admin%20of%20the%20sharepoint%20site%2C%20but%20wanted%20to%20contact%20that%20team%20how%2Fwhy%20this%20field%20is%20null%20and%20would%20appreciate%20any%20suggestions%20I%20may%20be%20able%20to%20present%20them%20to%20expedite%26nbsp%3Bthe%20process.%20Assuming%20this%20the%20key%2Fvalue%20pair%20that%20should%20contain%20the%20name%20of%20the%20folder.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20need%20to%20build%20out%20a%20list%20of%20folders%20then%20upon%20user%20interaction%20show%20all%20the%20items%20in%20that%20folder.%20If%20you%20had%20an%20example%20endpoint%20for%20content%20in%20a%20specific%20folder%20that%20would%20be%20very%20helpful%20too.%26nbsp%3B%20Documentation%20is%20a%20little%20limited%20on%20this%2C%20unless%20I%20am%20missing%20something%2C%20so%20if%20you%20have%20a%20more%20comprehensive%20reference%20than%20I%20have%20found%2C%20I%20can%20dig%20in%20on%20my%20own%2C%20too.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EThank%20you%20for%20your%20time.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EJamie%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hello All,

Does SharePoint allow to retrieve all folders in a List? (Not a Doc Library). Just a basic List.

I am using SharePoint Online.

I tried /_api/web/lists/GetById('${ListID}')/Folders without luck.

 

And please can someone share a link to a comprehensive SPO Lists & Doc Lib REST API reference?

I only have this https://msdn.microsoft.com/en-us/library/office/jj860569.aspx#Reference .

Is it not outdated?

3 Replies
Best Response confirmed by imbourg (Occasional Contributor)
Solution

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

Highlighted

Thank you @Joel Rodrigues

 

I also found this: 

/_api/web/lists/GetById('${ListID}')/Items?$filter=FSObjType eq 1

But the problem is that just like yours, the response does not give the folders' names.

Then I found:

 

/_api/web/lists/GetById('${ListID}')/rootFolder/Folders

It 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

Highlighted

@imbourg 

 

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