3

I'm creating low-trust addin for sharepoint and trying to get list of all site collections using CSOM. This code works good for SharePoint Online:

using (var context = GetAppOnlyClientContext(hostUrl)) 
{ 
   var tenant = new Tenant(context); 
   var siteProperties = tenant.GetSiteProperties(0, true); 

   context.Load(siteProperties); 
   context.ExecuteQuery(); 

   var result = siteProperties.ToList(); 
}

But when I'm trying to run this code on SP 2016 instance, I get following exception:

Cannot find stub for type with id {268004ae-ef6b-4e9b-8425-127220d84719}. The specified server may not support APIs used in this operation.

I'm using CSOM version 16.0.

So the question is: Can I receive list of site collection using CSOM? If yes, how can I avoid this error?

0

For 2016, you can follow the instructions here: https://blogs.msdn.microsoft.com/vesku/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom/

Except you need to make the following changes:

  1. You don't need step #1 since the update is already applied.
  2. For the powershell script, be sure to change the version is from 15 to 16.
  3. Skip step 3 since the dll's you have already include the needed references to create the sites.
  4. Run this command the same as is documented.
2

This method has finally been added in October 2016 PU.

https://blogs.technet.microsoft.com/sharepointdevelopersupport/2016/10/11/new-csom-api-for-sharepoint-server-2016-tenant-getsiteproperties/

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.