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,

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.

  • Yeah your's better. No need to iterate sub webs. – dstarkowski Sep 1 '15 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.

  • A bit earlier :) – Akhoy Sep 1 '15 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 Feb 28 '18 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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