Retrieve Root Site and Subsites Using SharePoint REST API

Jyoti Kale 0 Reputation points
2025-02-12T07:17:16.6233333+00:00

I want to fetch the root site and all subsites of a SharePoint site collection using the REST API.

Could anyone assist with this?

Thanks.

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xyza Xue_MSFT 30,176 Reputation points Microsoft External Staff
    2025-02-12T08:31:26.94+00:00

    Hi @Jyoti Kale ,

    Thank you for posting in this community.

    To retrieve the root site and all subsites of a SharePoint site collection using the REST API, you can follow these steps:

    1. Fetch the Root Site: Use the following endpoint to get the root site of the site collection:
       GET https://{site_url}/_api/site
    
    1. Fetch All Subsites of a SharePoint site collection: To retrieve all subsites, you can use the following endpoint:
            GET https://{site_url}/_api/web/webs
      

    Output:

    User's image

    User's image

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.