I am using CSOM, trying to create a template where the site already has document sets enabled. However, when I get the site script from the template site and I apply it to a different site, applying the template fails since the Document Set Content Type is not found. Is there something I'm missing when modifying the TenantSiteScriptSerializationInfo?

Here is the code I'm using to retrieve a site script

    var serializationInfo = new TenantSiteScriptSerializationInfo()
      IncludeBranding = true,
      IncludeRegionalSettings = true,
      IncludeSiteExternalSharingCapability = true,
      IncludeLinksToExportedItems = true,
      IncludedLists = new string[] { "Test%20Library", "Other%20Library" }
  var script = tenant.GetSiteScriptFromSite(url);
  return script.Value.JSON;

Here is the code for adding a site script to SPOnline server:

var context = new ClientContext(this._adminUrl);
context.ExecutingWebRequest += (sender, e) => e.WebRequestExecutor.RequestHeaders["Authorization"] = "Bearer " + token;
var tenant = new Tenant(context);
var content = await this.GetSiteScript();
var scriptInformation = new TenantSiteScriptCreationInfo()
    Title = "My Template",
    Description = "New Template",
    Content = content
var siteScript = tenant.CreateSiteScript(scriptInformation);

context.Load(siteScript, s => s.Id, s => s.Title);
return siteScript.Id;
  • Please take a look at this similar issue: sharepoint.stackexchange.com/questions/199336/… Jan 26 at 21:19
  • Thank you Martin. The issue I’m having isn’t with creating document sets through the API. That works for me. The issue is when it comes to creating a site script to create a template, the document set is either not copying over to the site script or something else is happening Jan 27 at 23:59

1 Answer 1


Content types are not copied over for the site collection, although the content-types will be attempted to be added to the library you are copying over into the template. In my case, the template itself does not add Document Sets over to the site Collection template, but it adds it to the libraries that are being copied over ("Test Library" and "Other Library").

For the site design to work accurately, you need to enable document sets in the site collection before applying the site design.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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