I have a document library with multiple level folder structure, I want to fetch the server relative URL of individual folder by their name.

For example: Folder structure in lib like this: Document Library > Folder => subfolder1 => subfolder2

If I pass Name='Folder', it should return /Document Library/Folder

If I pass Name='subfolder2', it should return /Document Library/Folder/subfolder1/subfolder2

I tried below restAPI:

_api/web/lists/GetByTitle('Documents')/RootFolder?$expand=Folders/Folders&$Filter=Name eq 'subfolder2'

But it returns extra folder details as well.

Any extra parameter I can add to my rest URL to filter out extra folder details?


1 Answer 1


Modified the REST URL a bit:

_api/web/lists/GetByTitle('Documents')/Items?$expand=Folder&$select=Title,FileLeafRef,Folder/ServerRelativeUrl&$filter=(FSObjType eq 1 and Title eq 'subfolder2')
  • 1
    One catch here is: You (or any other user) have to update the Title column of folder every time you create new folder. Nov 3, 2020 at 12:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.