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
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 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.
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.
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.
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.
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 Request
HTTP 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 Request
HTTP 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.
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 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.
WarrenBelz
146,769
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,091
Most Valuable Professional