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 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/siteTo 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 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 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 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 Accept | MS Graph HTTP Request v2.0 or v2.1 Header Accept |
| application/json; odata=verbose | application/json; odata.metadata=full |
| application/json; odata=minimalmetadata | application/json; odata.metadata=minimal |
| application/json; odata=nometadata | application/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 information
The results of the _api/v2.1 requests are below:
HTTP 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.