Hi @Pushpanjay Umrao ,
I reviewed the issue description, the core question is how to list all sites? Right? If so, please take a reference of the below method:
In the tenant admin site, there is a hidden list named DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS
that store a copy of aggregated site collections data from all contentdb.
You can get it like below:
var siteurl = "https://tenant-admin.sharepoint.com" // Tenant site, not regular site!
List AllSiteList = clientContext.Web.Lists.GetByTitle("DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS");
ListItemCollection AllSiteItems = AllSiteList.GetItems(CamlQuery.CreateAllItemsQuery());
clientContext.Load(AllSiteItems);
clientContext.ExecuteQuery();
The corresponding rest api is:
-
/_api/web/lists/getbytitle('DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS')/items
Best Regards,
Baker Kong
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.