I'm looking for a way to get all the site collections for a particular tenant through API.
The URL that lists all site collections is
https://<tenantName>-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx
How can I get this info using a REST API endpoint?
Update 1:
This API call
https://{tenantName}-admin.sharepoint.com/_api/search/query?querytext='contentclass:sts_site'
Doesn't work for me.
I get the following error (500 Internal Server Error)
{
"error": {
"code": "-1, Microsoft.Office.Server.Search.REST.SearchServiceException",
"message": {
"lang": "en-US",
"value": "An unknown error occurred."
}
}
}
FYI: I am using Client Credentials Flow to get the access token. App level permissions list doesn't have any permission to Search like in Delegated permissions. Could that be the issue?