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
The following REST endpoint
/_api/site/rootWeb/webinfos
will return the collection of sub webs (WebInfo
objects) under root web
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")'
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)