Can we create Modern Team site and Communication sites using CSOM in SharePoint Online ?
I tried to create the modern site for GROUP#0 and SITEPAGEPUBLISHING#0 with the below code sample and getting the error
The web template SITEPAGEPUBLISHING#0 is not available for sites on this tenant.
string tenantadminurl = tenantAdminUrl.Replace("-admin", "").Trim() + "/sites/";
// TemplateName = "Modern Team Site", TemplateID = "GROUP#0"
// TemplateName = "Modern Communication", TemplateID = "SITEPAGEPUBLISHING#0"
//string siteurl = tenantadminurl + objSiteCollectionDetails.SiteTitle;
// string tenanturl = tenantAdminUrl.Replace("-admin", "").Trim();
string siteurl = "https://tarundev-admin.sharepoint.com" + "/sites/"+"SampleMDsite";
// string siteurl = "https://tarundev.sharepoint.com" + "/sites/"+"SampleMDsite";
objSiteProperties.SiteUrl = siteurl;
var tenant = new Tenant(context);
var properties = new SiteCreationProperties()
{
CompatibilityLevel = 15,
Title = objSiteCollectionDetails.SiteTitle,
Url = siteurl,
Owner = owner,
Template = objSiteCollectionDetails.SiteTemplate,
StorageMaximumLevel = 1,
UserCodeMaximumLevel = 300
};
tenant.CreateSite(properties);
context.ExecuteQuery();
Can anyone guide me in the right way.