4

I'm looking for a way to get the list of site collections for my O365 Subscriptions. Now I have come across various answers to this but NONE of them works for me. I am using Client Credentials Flow to get the access token which means >>> APP Only Token. I have tried

https://{tenantName}-admin.sharepoint.com/_api/search/query?querytext='contentclass:sts_site'

and I get

500 Internal server error
{
  "error": {
    "code": "-1, Microsoft.Office.Server.Search.REST.SearchServiceException",
    "message": {
        "lang": "en-US",
        "value": "An unknown error occurred."
    }
  }
}

I have come across the following links

And

The last link appeared to be promising and I created the LIST(QueryPropertiesTemplate) as mentioned, but how am I supposed to get the FARM ID? Since this is Sharepoint Online and not on premise.

Any help with this?

1

Is it not "-admin" in the URL that is your problem. I tried with my tenant and without admin and got an response. enter image description here

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • If you have a new question, please use the "Ask Question" button at the top of the page. This section is for answers only, not subsequent questions or discussions. Thank You. – Benny Skogberg Dec 4 '18 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.