6

I am working on a requirement to display all sub sites and list/Libraries inside sub site using REST. I am able to fetch Sub sites and List/Libraries but i am not able to fetch List/Library Url's. Can anyone please help me in fetching List URL's using REST API.

Thanks,

2 Answers 2

7

You can use this URL : http://rootsite/_api/Web/webs?$expand=Lists/RootFolder&$select=Lists/RootFolder/ServerRelativeURL. This will return the subwebs along with the lists property expanded for each subweb. The Lists property will return all the lists and libraries associated with the subsite.

1
  • Yeah your's better. No need to iterate sub webs. Commented Sep 1, 2015 at 18:37
9

Try this one:

/_api/Web/Lists?$select=Title,RootFolder/ServerRelativeUrl&$expand=RootFolder

Then iterate all results and select list.RootFolder.ServerRelativeUrl.

2
  • A bit earlier :)
    – Akhoy
    Commented Sep 1, 2015 at 18:03
  • If you're in a modern enough environment, JavaScript's map() function can help with the iteration part: let listInfos = items.map((item: any) => { return { title: item.Title, url: item.RootFolder.ServerRelativeUrl }; });
    – teeth7
    Commented Feb 28, 2018 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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