I'm trying to create a team site and get the following error message
Site url https://myurl/sites/mylongsitename exceeds maximum length of 256.
The url itself is under the 256 limit, I've also tried appending "Shared Documents" and "Shared%20Documents" and its still under the limit. Does anything else get appended to increase the length.
Is there a way for me to validate this before attempting to create it?
This is the code I am using source
using (ClientContext tenantContext = new ClientContext("https://yoursite-admin.sharepoint.com/"))
{
//Authenticate with a Tenant Administrator
SecureString passWord = new SecureString();
foreach (char c in "password".ToCharArray()) passWord.AppendChar(c);
tenantContext.Credentials = new SharePointOnlineCredentials("[email protected]", passWord);
var tenant = new Tenant(tenantContext);
//Properties of the New SiteCollection
var siteCreationProperties = new SiteCreationProperties();
//New SiteCollection Url
siteCreationProperties.Url = "https://yoursite.sharepoint.com/sites/codesite";
//Title of the Root Site
siteCreationProperties.Title = "Site Created from Code";
//Email of Owner
siteCreationProperties.Owner = "[email protected]";
//Template of the Root Site. Using Team Site for now.
siteCreationProperties.Template = "STS#0";
//Storage Limit in MB
siteCreationProperties.StorageMaximumLevel = 100;
//UserCode Resource Points Allowed
siteCreationProperties.UserCodeMaximumLevel = 50;
//Create the SiteCollection
SpoOperation spo = tenant.CreateSite(siteCreationProperties);
tenantContext.Load(tenant);
//We will need the IsComplete property to check if the provisioning of the Site Collection is complete.
tenantContext.Load(spo, i => i.IsComplete);
tenantContext.ExecuteQuery();
//Check if provisioning of the SiteCollection is complete.
while (!spo.IsComplete)
{
//Wait for 30 seconds and then try again
System.Threading.Thread.Sleep(30000);
spo.RefreshLoad();
tenantContext.ExecuteQuery();
}
Console.WriteLine("SiteCollection Created.");
}
The total length of the url is 148