[SPO] Sites and their IDs

OK, since I get pretty often asked: how to I get a site’s ID or now, I have a site ID, how to I get the URL of the site?

Well, here’s how to do it:

Get SiteID: https://tenant.sharepoint.com/teams/site/_api/site/id

The response is something like: <d:Id xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata xmlns:georss=”http://www.georss.org/georss xmlns:gml=”http://www.opengis.net/gml m:type=”Edm.Guid>aa6733a3-1d04-4db4-b35c-9ee5674c3004</d:Id>

Get siteURL from ID: https://tenant.sharepoint.com/_api/SP.Site.GetUrlById(guid’aa6733a3-1d04-4db4-b35c-9ee5674c3004′)

The response will be like:

<d:GetUrlById xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata xmlns:georss=”http://www.georss.org/georss xmlns:gml=”http://www.opengis.net/gml>https://tenant.sharepoint.com/teams/site</d:GetUrlById>

 

Enjoy!