I'm trying to create a spreadsheet with a list of all the folders and sub-folders in a SharePoint Site. I used this solution here: Get complete subfolder-structure from library/folder and was able to get it to work - mostly.
I've been testing this on a smaller SharePoint site with only 2 layers of subfolders to ensure it's working properly before implementing on my massive SharePoint site. The problem I'm running into is that the folder titles are coming up as "null" values and the Server Relative URL for each folder also doesn't include the name of the folders/sub-folders.
What it should be producing, is the following:
Title="Test Folder A"; Server Relative URL="sites/SiteName/Document Library"
Title="Test Folder B"; Server Relative URL="sites/SiteName/Document Library"
Title="Test Folder C"; Server Relative URL="sites/SiteName/Document Library/Test Folder A"
But what it's producing is:
Title=null; Server Relative URL="sites/SiteName/Document Library"
Title=null; Server Relative URL="sites/SiteName/Document Library"
Title=null; Server Relative URL="sites/SiteName/Document Library/Test Folder A"
So I know that the code is properly looping through all the folders and sub-folders, but I'm not able to properly retrieve or display that data as I'm looping through. When I look at the outputs from the Send an HTTP request to SharePoint action, it's also showing these null values for Title.
I tried running the script again but for a different document library in the same site and I was able to get the FIRST folder name to appear, but the rest came up null:
Title="Test Folder A"; Server Relative URL="sites/SiteName/Document Library B"
Title=null; Server Relative URL="sites/SiteName/Document Library B"
Title=null; Server Relative URL="sites/SiteName/Document Library B/Test Folder A"
My automation has the same steps as the solution linked above. Any thoughts on what I'm doing wrong or anything that I'm missing?
Current outputs:
EDIT/UPTDATE TO QUESTION: Per the recommended solution from @jleture I was able to get the flow to run with $filterFSObjectType eq 0
(not $filter=FSObjectType eq 0
with the equal sign; and I've found that using %20
or a space doesn't change the results). However, the flow is still pulling all files, not just folders, into the results list. Here is my updated Uri on the HTTP request:_api/web/lists/getbytitle('Training Materials Library')/items?$select=Title,FileLeafRef,FileDirRef&$filterFSObjectType eq 0
I assumed it's unable to filter by file type because it's not listed in the URI and tried adding in FSObjectType
into the inquiry: _api/web/lists/getbytitle('Training Materials Library')/items?$select=Title,FileLeafRef,FileDirRef,FSObjectType&$filterFSObjectType eq 0
This gives me an error:
{"odata.error":{"code":"-1, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The field or property 'FSObjectType' does not exist."}}}
clientRequestId: 0974a93a-c535-4a1f-9739-bbfa52a6e44e
serviceRequestId: a6ee6aa1-b0e2-7000-2ab4-d6e5af5cd936
I've also tried just Type
and ObjectType
with no luck. Am I on the right path? Or is there another reason why it's not able to filter out files and just pull folder names?