Thursday, August 20, 2015

Fix problem with missing API error when create site collection using client object model in Sharepoint on-premise

With April 2014 CU MS introduced possibility to create site collection using client object model: see Provisioning site collections using SP App model in on-premises with just CSOM. April 2014 CU requires SP1 for Sharepoint 2013 be installed. If you will try to run the code sample from provided link and create site collection using CSOM with these updates, you will get the following error:

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

However you may face with this error even if all necessary updates are installed: this is what happened on one of our environments. When create site collection using CSOM you need to have special separate site collection which will be like tenant admin site collection in Sharepoint online. Exactly for this “admin” site collection you will need to execute 2nd script from Vesa’s article:

   1: $siteColUrl = http://dev.contoso.com
   2:  
   3: $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
   4: if ($snapin -eq $null) 
   5: {
   6:     Write-Host "Loading SharePoint Powershell Snapin"
   7:     Add-PSSnapin "Microsoft.SharePoint.Powershell"
   8: }
   9:  
  10: $site = get-spsite -Identity $siteColUrl
  11: $site.AdministrationSiteType =
  12:     [Microsoft.SharePoint.SPAdministrationSiteType]::TenantAdministration

On our environment we had 2 web applications:

We needed to create site collection in one of them (http://example1.com) under sites managed path. As admin site collection was not needed for anything except specifying it during site creation we decided to use root site collection in 2nd web application for that, because already had it. As result we got error message shown above.

In order to solve the issue we created site collection in the same web application http://example.com/sites/admin and ran above PowerShell script for this site collection. After that error disappeared and we were able to create site collection in 1st web application.

No comments:

Post a Comment