web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Sharepoint Site Collec...
Power Automate
Unanswered

Sharepoint Site Collection Id and Site Web Id Information using HTTP Request Uri _api/Site _api/Web or _api/v2.1

(6) ShareShare
ReportReport
Posted on by 6,519 Moderator

In my attempt to come up with a better way to make Document Sets in a Document Library using HTTP Request  I needed to understand the difference in using a Uri _api/Site and _api/Web within an HTTP request to SharePoint. This lead me to needing to know the difference between a SharePoint Site Collection and a SharePoint Site.

 

https://learn.microsoft.com/en-us/sharepoint/sites/sites-and-site-collections-overview 

 

Figure of Site Collection StructureFigure of Site Collection Structure

 

It is easy to understand that the Site Collection is all of the Sites for an entity, but it can become confusing when looking at the URI that is written for making HTTP request to a SharePoint from Power Automate. The Uri will use either _api/site or _api/web when making requests.

 

If you use the URI _api/site then you will always be referring to the Site Collection or the Top-Level Site in the HTTP request. Even if the Site Address of the HTTP request is to a subsite, the request will return info about the Site or Site Collection.

 

If you use the URI _api/web then you will be referring to the Site that is based on the Site Address

 

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom#construct-rest-urls-to-access-sharepoint-resources 

 

To access a specific site collection, use the following construction:

https://{site_url}/_api/site

To access a specific site, use the following construction:

https://{site_url}/_api/web

 

 

Below are example HTTP requests to get the information:

 

Site Collection – uri: _api/site

 

 

_api/site

 

 

 

Site Collection Top-Level Site – uri: _api/site/rootweb

 

 

_api/site/rootweb

 

 

 

Parent Site of the Site Address in the HTTP Request – uri: _api/web/parentweb

 

 

_api/web/parentweb

 

 

 

Site Level – uri: _api/web

 

 

_api/web

 

 

 

Below are example HTTP requests that utilize the above Uri:

HTTP Requests - Site and Site CollectionHTTP Requests - Site and Site Collection

 

Here are the results of the above requests:

Note: The Uri in the results differ from the photo of the requests because I added additional ?$select= options to make the returned results look cleaner.

Results of the RequestsResults of the Requests

Each of the Requests and the Results use the same Site Address but return different site level information depending on the use of _api/site or _api web.

 

I have made another photo/view that consolidates the information to compare the Id’s and how they are used across the Site Collection.

Site Collection OutlineSite Collection Outline

 

The results will only use the term "Id" and you have to know what type of request was made to determine if it is referencing the Site Collection Id with is the Site-Id or if it is referencing the individual Site Id which would be the Web-Id.

 

Method 2.0 or 2.1 HTTP Request for Site Collection and Site Id Information:

 

The use of Microsoft Graph http requests in Power Automate is currently less documented since it is relatively newer. However, you can get the same information with some adjustment to the HTTP requests. See the link below for _api/v2.0 with SharePoint information.

https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph 

 

When using the _api/v2.1 requests, you can’t get all the information with the same Site Address as previously shown in my examples. You need to change the Site Address and then put the HostName in the Uri.

 

There is an advantage with the _api/v2.1 since it has an endpoint called sharepointIds which can be used in most HTTP requests to get specific Ids. You can look at the details here.

https://learn.microsoft.com/en-us/graph/api/resources/sharepointids?view=graph-rest-1.0 

 

The 2.0 or 2.1 HTTP Request does not have the same issue of _api/site vs _api/web. All of the Uri will utilize Site. You do not put in a different Web or Site based on the request.

 

Note: When making HTTP requests using _api/v2.0 or _api/v2.1 the Accept header that determine return content is different.

Regular HTTP Request Header AcceptMS Graph HTTP Request v2.0 or v2.1 Header Accept
application/json; odata=verboseapplication/json; odata.metadata=full
application/json; odata=minimalmetadataapplication/json; odata.metadata=minimal
application/json; odata=nometadataapplication/json; odata.metadata=none

 

The format of the v2.1 request are below:

 

 

_api/v2.1/sites/{hostname}

 

 

 

The format of the v2.1 request for endpoint sharePointIds:

 

 

_api/v2.1/sites/{hostname}?$select=sharepointIds

 

 

 

Below are examples of HTTP requests that will get Site Collection and Site Ids using the endpoint sharepointIds in the Uri:

HTTP Request v2.1 for Site informationHTTP Request v2.1 for Site information

 

The results of the _api/v2.1 requests are below:

HTTP v2.1 Request ResultsHTTP v2.1 Request Results

 

 

While it seems like the first example of HTTP requests are more flexible because you can get much of the Site Collection information using a subsite as the Site Address, the v2.1 method is more straightforward. Put in the Site Address for where you want information from and you can get the specific Ids. It also labels the results as siteId for the Site Collection Id and the webId for the Site Id when using the endpoint sharepointIds.

 

Categories:
I have the same question (0)
  • Verified answer
    wskinnermctc Profile Picture
    6,519 Moderator on at

    There is an additional method when using _api/v2.1 which allows you to use the Site Address but return information for another site. It isn't very practical, but it does show more about how the _api/v2.1 works.

     

    In the Uri of the request you can include the SiteCollectionId and WebId of another site, and the request will return information from that site instead.

     

    So first I am showing the general examples that were used in the initial post. Where the Uri just contains the HostName and it returns information for the site within the Site Address.

     

    HTTP Request V2 - Site Level RequestHTTP Request V2 - Site Level RequestHTTP Request V2 - Site Level Request SharePointIdsHTTP Request V2 - Site Level Request SharePointIds

     

    Both of the previous photos will return information for the "Telework" Site in the Site Address.

     

    The alternative method to get a different site is shown below.

    HTTP V2 - SiteCollection RequestHTTP V2 - SiteCollection RequestHTTP V2 - SiteCollection Request SharePointIdsHTTP V2 - SiteCollection Request SharePointIds

     

    The requests use the ids to address other sites. The reason this works is because it is using the MS Graph format of how to address items within the Graph Explorer.

    https://learn.microsoft.com/en-us/graph/api/resources/sharepoint?view=graph-rest-1.0#sharepoint-api-root-resources 

     

    https://learn.microsoft.com/en-us/graph/api/resources/sharepoint?view=graph-rest-1.0#note-for-existing-sharepoint-developers 

     

    The request Uri is in the format:

    _api/v2.1/sites/{hostname},{sitecollectionid},{site-webid}

     

    Or to use the function "SharePointids" the Uri is format:

    _api/v2.1/sites/{hostname},{sitecollectionid},{site-webid}?$select=sharepointids

     

    Below is a result comparing the methods:

    Compare Uri of HTTP V2 requestCompare Uri of HTTP V2 request

     

    I hope this information is helpful and at least gets people testing the use of _api/v2.0 or _api/v2.1 in their flow HTTP requests.

     

  • NickTT Profile Picture
    236 on at

    I am looking to try and have a workflow that would Resubmit a failed document classification with Syntex. Every now and then SharePoint errors out but if you submit it again later, it works. So I am looking at this API.

    https://github.com/SharePoint/sp-dev-docs/blob/main/docs/apis/syntex/rest-createclassificationreques...

     

    I used your info above, thanks, to get the Site and Web IDs but how to I pull the guid of the document? The API won't take the document ID that is stored as an INT.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard