Forum Discussion

Michael Schau's avatar
Michael Schau
Copper Contributor
May 18, 2017

SiteProperties.NewUrl not working

Has anyone had any luck changing the SiteCollection url in SharePoint Online using CSOM?

 

https://msdn.microsoft.com/en-us/library/office/microsoft.online.sharepoint.tenantadministration.siteproperties.newurl.aspx

 

Here's a code sample (using OfficedDevPnP extensions) 

var tenant = new Tenant(context);

var siteProperties = tenant.GetSitePropertiesByUrl("<CurrentUrl>", false);
tenant.Context.Load(siteProperties);
tenant.Context.ExecuteQueryRetry();

siteProperties.NewUrl = "<NewUrl>";
siteProperties.Update();

tenant.Context.ExecuteQueryRetry();

I get an ArgumentException with the following message

The requested operation is not supported for site: <SiteUrl>

  • what is the context when you add

    var tenant=tenant(context) ??

Resources