I am trying to get all subsites from a parent web using REST API. I tried following query which shows "The page cannot be found".

mysite/_api/web/parentWeb/webs

Suppose, your site url is like this: http://yourcompany.com/sites/projects

Then in order to get sus site under projects site use:

http://yourcompany.com/sites/projects/_api/web/webs

Suppose you have site under projects named "Project1" and you want to find subsite under it, then use:

http://yourcompany.com/sites/projects/Project1/_api/web/webs
  • thanks, unfortunately the url can be changed. I wanted to get all siblings by going up one step and get all subsites. – Medes Mar 10 '14 at 8:37

The following REST endpoint

/_api/site/rootWeb/webinfos

will return the collection of sub webs (WebInfo objects) under root web

Using Search REST API

The following REST query demonstrates how to find all webs under the specified path:

/_api/search/query?querytext='path:https://contoso.sharepoint.com/*'&refinementfilters='contentclass:equals("STS_Web")'
  • thanks, this piece of code is running almost everywhere and I want to get all siblings by going up only one step and get all subsites. – Medes Mar 10 '14 at 8:35
  • Medes,in that case you could utilize search based approach in order to return all webs, the answer has been updated. – Vadim Gremyachev Mar 10 '14 at 8:52
  • yes, still I need to have a dynamic value of "Path"? am I right? – Medes Mar 10 '14 at 9:03
  • it depends, you could specify site collection path (static), or if needed to return results relative to specific parent web, then path should be constructed (dynamic) – Vadim Gremyachev Mar 10 '14 at 9:17
  • Vadim, I tested your query but it didn't work, – Medes Mar 10 '14 at 10:30

For up to date list (contrary to search) that also works for users with read-only permissions (contrary to /_api/web/webs), use this REST api:

http://<sitecollection>/<site>/_api/web/GetSubwebsFilteredForCurrentUser(nWebTemplateFilter=-1,nConfigurationFilter=-1)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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