SharePoint 2013 Apps: Get list of site collections using REST API

Let me clear that it is not possible to fetch a list of site collection neither via REST nor by using JSOM. But there is a workaround i.e. by utilizing SharePoint Search Query REST/JSOM API. For that a basic search site collection should already be configured and crawled. Then in our code, we only need to specify the query contentclass:sts_site to return sites results. Following is the working code snippet that I used to achieve that:

function GetAllSiteCollectionsInCurrentWebApp(currentUser) {

var queryText = 'contentclass:sts_site';
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/search/query?querytext='" + queryText + "'";
var executor = new SP.RequestExecutor(_spPageContextInfo.webAbsoluteUrl);
url: url,
method: "GET",
headers: { "Accept": "application/json;odata=verbose" },
success: function (data) {
//RetrieveSiteCollectioninWebApp(data, currentUser)
error: function (data) {




Vaqar Hyder



Siebenb�rgen Stra�e 2/1, Korntal-M�nchingen, 70825, PK

Hire me on

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *