How to List Folders in a SharePoint Document Library Using Power Automate


The Problem

If you've ever tried to dynamically retrieve a list of folder names from a SharePoint Document Library inside a Power Automate Cloud Flow, you know it's not as straightforward as it should be. There's no single out-of-the-box action that simply returns folder names from a specific subfolder path.

This was exactly the challenge: getting all folder names listed inside a specific subfolder — Documents > - TRIPS — in a SharePoint site, programmatically through Power Automate, so the flow could process or reference each trip folder dynamically. List Folders in SharePoint with Power Automate


Why This Is Tricky

Power Automate's built-in "Get files (properties only)" action can filter for folders using FSObjType eq 1, but it doesn't handle deep folder paths reliably. When you need folders from a specific subfolder (not the root of the library), you need to go a level deeper using the SharePoint REST API.

Additionally, SharePoint internally stores the "Documents" library as Shared Documents, and folder names with special characters (like a leading dash - TRIPS) must be referenced exactly — causing silent failures if the path is even slightly off.

HashTUrn

The Solution: SharePoint REST API via HTTP Request Action

The cleanest and most reliable method is using the "Send an HTTP request to SharePoint" action in Power Automate with the SharePoint REST API.

Step 1 — Find Your Exact Folder Path

Navigate to your SharePoint site and open the target folder. Copy the URL from your browser. For example:

https://asktravelworld.sharepoint.com/sites/TW/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2FTW%2FShared%20Documents%2F%2D%20TRIPS

From this URL, decode the path:

/sites/TW/Shared Documents/- TRIPS

⚠️ Important: Note any special characters exactly. In this case, the folder is named - TRIPS (with a hyphen and space). This must be used verbatim in your API URI.


Step 2 — Build the Power Automate Flow

Action: Send an HTTP Request to SharePoint

Field Value
Site Address https://asktravelworld.sharepoint.com/sites/TW
Method GET
URI _api/web/GetFolderByServerRelativeUrl('/sites/TW/Shared Documents/- TRIPS')/Folders

Click "Show advanced options" and add this header:

Key Value
Accept application/json;odata=verbose

Step 3 — Parse the JSON Response

Add a Parse JSON action:

  • Content: Body from the previous HTTP step
  • Schema: Generate from sample by running the flow once, or use the structure below:
{
  "type": "object",
  "properties": {
    "d": {
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "Name": { "type": "string" },
              "ServerRelativeUrl": { "type": "string" },
              "UniqueId": { "type": "string" },
              "ItemCount": { "type": "integer" }
            }
          }
        }
      }
    }
  }
}

Step 4 — Loop Through the Folders

Add an Apply to each action:

  • Select output from previous steps: body/d/results

Inside the loop, use these dynamic values:

Field Description
Name The folder name (e.g., "Dubai 2024")
ServerRelativeUrl Full relative path of the folder
UniqueId Unique GUID of the folder
ItemCount Number of items inside the folder

Complete Flow Summary

[Trigger]
  ↓
[SharePoint → Send an HTTP request to SharePoint]
  Site: https://asktravelworld.sharepoint.com/sites/TW
  Method: GET
  URI: _api/web/GetFolderByServerRelativeUrl('/sites/TW/Shared Documents/- TRIPS')/Folders
  Header: Accept → application/json;odata=verbose
  ↓
[Data Operations → Parse JSON]
  Content: Body of previous step
  ↓
[Control → Apply to each]
  Input: body/d/results
  ↓
  [Use: Name, ServerRelativeUrl, UniqueId, ItemCount]

Common Issues & Fixes

Problem Fix
404 Not Found Double-check the folder path. Try Shared Documents vs Documents.
Folder name with special chars not found Use exact name including dashes, spaces. URL-encode if needed.
Empty results The subfolder may be empty or the path is pointing to root.
Schema generation fails Run the flow once manually and copy the raw body output to generate schema.

Key Takeaway

When you need to list folders from a specific subfolder in SharePoint via Power Automate:

  1. ✅ Use "Send an HTTP request to SharePoint" — not the basic file/folder actions
  2. ✅ Use the GetFolderByServerRelativeUrl(...) REST endpoint
  3. ✅ Grab your exact path from the browser URL when inside the target folder
  4. ✅ Add the Accept: application/json;odata=verbose header
  5. ✅ Parse the response and loop through body/d/results

This approach is reliable, works on nested folders at any depth, and gives you rich metadata for each folder.


Related Topics

  • How to list files inside a SharePoint folder with Power Automate
  • Using SharePoint REST API with Power Automate HTTP actions
  • Building dynamic SharePoint folder-based workflows

Found this helpful? Share it with your team or drop a comment below. If you hit a different error or have a variation of this setup, let me know in the comments!

Want to automate your business? Book a Free Strategy Call