SiteProperties.NewUrl not working

%3CLINGO-SUB%20id%3D%22lingo-sub-71014%22%20slang%3D%22en-US%22%3ESiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71014%22%20slang%3D%22en-US%22%3E%3CP%3EHas%20anyone%20had%20any%20luck%20changing%20the%20SiteCollection%20url%20in%20SharePoint%20Online%20using%20CSOM%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fmicrosoft.online.sharepoint.tenantadministration.siteproperties.newurl.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fmicrosoft.online.sharepoint.tenantadministration.siteproperties.newurl.aspx%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere's%20a%20code%20sample%20(using%20OfficedDevPnP%20extensions)%26nbsp%3B%3C%2FP%3E%3CPRE%3Evar%20tenant%20%3D%20new%20Tenant(context)%3B%0A%0Avar%20siteProperties%20%3D%20tenant.GetSitePropertiesByUrl(%22%26lt%3BCurrentUrl%26gt%3B%22%2C%20false)%3B%0Atenant.Context.Load(siteProperties)%3B%0Atenant.Context.ExecuteQueryRetry()%3B%0A%0AsiteProperties.NewUrl%20%3D%20%22%26lt%3BNewUrl%26gt%3B%22%3B%0AsiteProperties.Update()%3B%0A%0Atenant.Context.ExecuteQueryRetry()%3B%3C%2FPRE%3E%3CP%3EI%20get%20an%20ArgumentException%20with%20the%20following%20message%3C%2FP%3E%3CP%3EThe%20requested%20operation%20is%20not%20supported%20for%20site%3A%20%3CSITEURL%3E%3C%2FSITEURL%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71406%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71406%22%20slang%3D%22en-US%22%3E%3CP%3EJust%20checked%20with%20reflector%20code%20is%20implemented%20but%20can%20not%20debug%20it%20%3A(%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71394%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71394%22%20slang%3D%22en-US%22%3E%3CP%3EYep%2C%20I've%20read%20it.%3C%2FP%3E%3CP%3EBut%20as%20mentioned%20it%20was%20posted%20more%20than%20a%20year%20ago.%20Just%20assumed%20that%20it%20was%20funtioning%20in%20%22Production%22%20by%20now.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71393%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71393%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%40Deleted%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24site%20%3D%20Get-PnPTenantSite%20%3CA%20href%3D%22https%3A%2F%2FMytenant.sharepoint.com%2Fsites%2Ftestsite%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2FMytenant.sharepoint.com%2Fsites%2Ftestsite%3C%2FA%3E%3C%2FP%3E%3CP%3E%24site.NewUrl%20%3D%20%22https%3A%2F%2F%3CSPAN%3EMytenant%3C%2FSPAN%3E.sharepoint.com%2Fsites%2Ftestsite2%22%3C%2FP%3E%3CP%3E%24site.Update()%3C%2FP%3E%3CP%3E%24site.Context.ExecuteQuery()%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20then%20I%20tried%20all%20variations%20of%20Urls%20for%20the%26nbsp%3B%3CSPAN%3E%24site.NewUrl%20%3D%20%22%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71390%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71390%22%20slang%3D%22en-US%22%3E%3CP%3Ehave%20you%20read%20this%3F%3C%2FP%3E%3CP%3E%3CSPAN%3Epublic%20%3C%2FSPAN%3E%3CSTRONG%3Eproperty%3C%2FSTRONG%3E%3CSPAN%3E%20Microsoft.Online.SharePoint.TenantAdministration.SiteProperties.NewUrl%20-%20The%20new%20URL%20for%20the%20site%20(updating%20this%20will%20trigger%20a%20site%20rename).%20%3C%2FSPAN%3E%3CSTRONG%3ENotice%3C%2FSTRONG%3E%3CSPAN%3E.%20This%20is%20not%20yet%20functional%20in%20the%20production%20when%20this%20blog%20post%20was%20written%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fblogs%2Fnew-sharepoint-csom-version-released-for-Office-365-march-2016%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.office.com%2Fblogs%2Fnew-sharepoint-csom-version-released-for-Office-365-march-2016%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71374%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71374%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7181%22%20target%3D%22_blank%22%3E%40Michael%20Schau%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20tried%20this%20with%20PnP%20PowerShell%2FCSOM%20and%20I'm%20finding%20the%20same%20results%20as%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20had%20a%20bit%20of%20a%20further%20play%20with%20this%20where%20I%20tried%20setting%20NewUrl%20to%20ServerRelativeUrls%20or%20just%20setting%20it%20to%20the%20site%20specific%20part%20of%20the%20Url%20but%20this%20gave%20me%20just%20different%20errors.%20I%20would%20expect%20that%20as%20you%20can%20only%20update%20the%20site%20specific%20bit%20that%20you%20might%20not%20include%20the%20full%20url%2C%20but%20unfortenately%20that%20didn't%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20thnk%20you%20might%20be%20right%20that%20this%20only%20works%20in%20on%20premises%20environments.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71370%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71370%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20I%20want%20to%20update%20the%20url.%20I'm%20creating%20a%20%22buffer%22%20of%20site%20collections%20and%20want%20to%20give%20them%20a%20proper%20url%20when%20they're%20taken%20into%20use.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20that%20doesn't%20work%2C%20then%20what%20is%20the%20usage%20of%20NewUrl%3F%3C%2FP%3E%3CP%3EWhy%20is%20it%20available%3F%20Is%20it%20because%20is%20only%20works%20on%20premises%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71365%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71365%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20I%20am%20just%20checking%20your%20code.%3C%2FP%3E%3CP%3EWhat%20are%20you%20trying%20to%20accomplish%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20i%20see%20you%20get%20the%20url%20then%20want%20to%20update%20the%20url%3F%3F%3C%2FP%3E%3CP%3EThat%20will%20not%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71312%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71312%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20tried%20both%20AppOnly%20context%20with%20full%20SiteCollection%20permissions%20and%20SharePointOnlineContext.%3C%2FP%3E%3CP%3ENeither%20works.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20however%20create%2Fdelete%20sitecollections%20and%20change%20other%20properties%2C%20but%20NewUrl%20doesn't%20work.%20So%20I%20believe%20my%20context%20is%20ok.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%40Deleted%26nbsp%3Byou're%20saying%20that%20it%20works%20for%20you%3F%20My%20ServerLibraryVersion%20is%26nbsp%3B16.0.6511.1201.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71208%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71208%22%20slang%3D%22en-US%22%3E%3CP%3Ehow%20do%20you%20build%20the%20context%20with%20creds%20etc%3F%3C%2FP%3E%3CP%3Ea%20example%20of%20mine%3C%2FP%3E%3CPRE%3E%20SharePointService%20sharePointService%20%3D%20new%20SharePointService()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20AuthenticationManager%20authenticationManager%20%3D%20new%20AuthenticationManager()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20using%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ClientContext%20adminContext%20%3D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20authenticationManager.GetSharePointOnlineAuthenticatedContextTenant(Info.TenantAdminUri.AbsoluteUri%2C%20Info.UserName%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Info.UserPassWord))%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20adminContext.RequestTimeout%20%3D%20Timeout.Infinite%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FPRE%3E%3CP%3Ehope%20it%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71178%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71178%22%20slang%3D%22en-US%22%3E%3CP%3EWell%2C%20it%20was%20added%20to%20CSOM%20a%20year%20ago%2C%20so%20I%20just%20assumed%20it%20was%20supported%20by%20now.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fblogs%2Fnew-sharepoint-csom-version-released-for-Office-365-march-2016%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.office.com%2Fblogs%2Fnew-sharepoint-csom-version-released-for-Office-365-march-2016%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20property%20also%20exists%20in%20the%20SharePoint%20Online%20documentation.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fmicrosoft.online.sharepoint.tenantadministration.siteproperties.newurl.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fmicrosoft.online.sharepoint.tenantadministration.siteproperties.newurl.aspx%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71144%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71144%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20this%20something%20new%3F%20So%20far%20this%20has%20not%20been%20supported...adding%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F369%22%20target%3D%22_blank%22%3E%40Vesa%20Juvonen%3C%2FA%3E%26nbsp%3Bto%20comment%20on%20this%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71024%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71024%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20is%20the%20Tenant%20Admin%20context.%3C%2FP%3E%3CP%3EEg.%26nbsp%3B%3CMYURL%3E-admin.sharepoint.com%3C%2FMYURL%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71020%22%20slang%3D%22en-US%22%3ERe%3A%20SiteProperties.NewUrl%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71020%22%20slang%3D%22en-US%22%3E%3CP%3Ewhat%20is%20the%20context%20when%20you%20add%3C%2FP%3E%3CP%3Evar%20tenant%3Dtenant(context)%20%3F%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

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.sit...

 

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>

13 Replies
Highlighted

what is the context when you add

var tenant=tenant(context) ??

Highlighted

It is the Tenant Admin context.

Eg. <myurl>-admin.sharepoint.com

Highlighted

Is this something new? So far this has not been supported...adding @Vesa Juvonen to comment on this

Highlighted

Well, it was added to CSOM a year ago, so I just assumed it was supported by now.

https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-march-2016

 

The property also exists in the SharePoint Online documentation.

https://msdn.microsoft.com/en-us/library/office/microsoft.online.sharepoint.tenantadministration.sit...

Highlighted

how do you build the context with creds etc?

a example of mine

 SharePointService sharePointService = new SharePointService();
            AuthenticationManager authenticationManager = new AuthenticationManager();
            using (
                ClientContext adminContext =
                    authenticationManager.GetSharePointOnlineAuthenticatedContextTenant(Info.TenantAdminUri.AbsoluteUri, Info.UserName,
                        Info.UserPassWord))
            {
                adminContext.RequestTimeout = Timeout.Infinite;
             
            }

hope it helps

Highlighted

I've tried both AppOnly context with full SiteCollection permissions and SharePointOnlineContext.

Neither works. 

I can however create/delete sitecollections and change other properties, but NewUrl doesn't work. So I believe my context is ok.

 

@Deleted you're saying that it works for you? My ServerLibraryVersion is 16.0.6511.1201.

Highlighted

Hi I am just checking your code.

What are you trying to accomplish?

 

Since i see you get the url then want to update the url??

That will not work.

Highlighted

Yes, I want to update the url. I'm creating a "buffer" of site collections and want to give them a proper url when they're taken into use.

 

If that doesn't work, then what is the usage of NewUrl?

Why is it available? Is it because is only works on premises?

Highlighted

Hi @Michael Schau,

 

I just tried this with PnP PowerShell/CSOM and I'm finding the same results as you.

 

I had a bit of a further play with this where I tried setting NewUrl to ServerRelativeUrls or just setting it to the site specific part of the Url but this gave me just different errors. I would expect that as you can only update the site specific bit that you might not include the full url, but unfortenately that didn't work.

 

I thnk you might be right that this only works in on premises environments.

 

 

 

 

Highlighted

have you read this?

public property Microsoft.Online.SharePoint.TenantAdministration.SiteProperties.NewUrl - The new URL for the site (updating this will trigger a site rename). Notice. This is not yet functional in the production when this blog post was written

https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-march-2016

 

Highlighted

Hi @Deleted,

 

I tried this:

 

$site = Get-PnPTenantSite https://Mytenant.sharepoint.com/sites/testsite

$site.NewUrl = "https://Mytenant.sharepoint.com/sites/testsite2"

$site.Update()

$site.Context.ExecuteQuery()

 

and then I tried all variations of Urls for the $site.NewUrl = ""

 

Highlighted

Yep, I've read it.

But as mentioned it was posted more than a year ago. Just assumed that it was funtioning in "Production" by now.

Highlighted

Just checked with reflector code is implemented but can not debug it :(