locked
REST API Get all folder and subfolder in one call API RRS feed

  • Question

  • Hi everyone,

    Have SharePoint support getting all folder and subfolder in document library in one call API?

    I checked around and tested many differ API for get folders, but still not find the solution in my case.

    If have anyone resolved this case, please help me. 

    Thank a lot,

    Danh Nguyen Alone

    Tuesday, January 14, 2020 10:12 AM

Answers

  • Hi Danh,

    We we can use the REST API below to get all the folders in document library.

    /_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef&$filter=FSObjType eq 1

    Or

    /_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef&$filter=ContentType eq 'Folder'

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, January 15, 2020 2:19 AM

All replies

  • Tuesday, January 14, 2020 3:49 PM
  • Hi Danh,

    We we can use the REST API below to get all the folders in document library.

    /_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef&$filter=FSObjType eq 1

    Or

    /_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef&$filter=ContentType eq 'Folder'

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, January 15, 2020 2:19 AM
  • Hi Dennis,

    It work success for me. Thanks so much.

    And can you provide Official link or blog to I can know more about this API.

    Thank a lot,

    Danh

    Wednesday, January 15, 2020 4:24 AM
  • Hi Danh,

    FSObjType (display name Item Type) is a built-in field, values are based on this enumeration.

    The following article for your reference.

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

    If my reply help you, please mark the reply as answer, it will make others who stuck with the similar issue easier to search for valid solutions in this forum.

    Best regards,
    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, January 15, 2020 6:26 AM
  • Hi Dennis, 

    Thank a lot.

    Danh

    Wednesday, January 15, 2020 7:21 AM
  • Hi Danh,

    Thanks for marking my reply as answer. I’m pleased to know that the information is helpful to you. I hope you are delighted with the service we provided you.
    Here I will provide a brief summary of this post for your information.

    Requirement:

    Getting all folder and subfolder in document library in one call REST API.

    Solution:

    Using the REST API below to get all the folders in document library.

    /_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef&$filter=FSObjType eq 1

    Or

    /_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef&$filter=ContentType eq 'Folder'
     

    Reference Links:

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

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, January 21, 2020 2:14 AM