SOLVED

CreateCopyJobs API doesn't work in SharePoint 2019

Copper Contributor

Hi all,

 

I need to create SharePoint 2019 functionality similar to what the Move and Copy Options in the old Site Manager ("Site Contents and Structure) did, i.e. move or copy pages or documents to another page/document library, while retaining the history of the files, updating the backward links, etc.

 

In SharePoint Online there are the Move To and Copy To buttons available, which use the CSOM/REST CreateCopyJobs API to accomplish that (at least the copy and move part...) and I was able to programmatically move files using that API.

 

This API is also available on-premise, but I can't get it to work. Not with SSOM, CSOM or REST.

Is it supposed to work on-premise?

And if yes, is there anything that I need to look out for to get it to work?

1 Reply
best response confirmed by Tobias Heck (Copper Contributor)
Solution

OK...after decompiling the 2019 version of the Microsoft.SharePoint.dll and checking the code for SPSite.CreateCopyJobs I now know why it doesn't work:

 

private SPCopyMigrationInfo CreateCopyJobInternal(Uri[] exportObjectUris, Uri destinationUri, SPCopyMigrationOptions options, Guid correlationId, bool? runOnFE, long totalBytes = 0L)
{
throw new InvalidOperationException();
}

[Obsolete("Use CreateCopyJobs instead")]
[ClientCallableMethod]
public SPCopyMigrationInfo CreateCopyJob(Uri[] exportObjectUris, Uri destinationUri, SPCopyMigrationOptions options)
{
throw new InvalidOperationException();
}

[ClientCallableMethod]
public List<SPCopyMigrationInfo> CreateCopyJobs(Uri[] exportObjectUris, Uri destinationUri, SPCopyMigrationOptions options)
{
throw new InvalidOperationException();
}

 

@ Microsoft: Are there any plans to implement those methods?

1 best response

Accepted Solutions
best response confirmed by Tobias Heck (Copper Contributor)
Solution

OK...after decompiling the 2019 version of the Microsoft.SharePoint.dll and checking the code for SPSite.CreateCopyJobs I now know why it doesn't work:

 

private SPCopyMigrationInfo CreateCopyJobInternal(Uri[] exportObjectUris, Uri destinationUri, SPCopyMigrationOptions options, Guid correlationId, bool? runOnFE, long totalBytes = 0L)
{
throw new InvalidOperationException();
}

[Obsolete("Use CreateCopyJobs instead")]
[ClientCallableMethod]
public SPCopyMigrationInfo CreateCopyJob(Uri[] exportObjectUris, Uri destinationUri, SPCopyMigrationOptions options)
{
throw new InvalidOperationException();
}

[ClientCallableMethod]
public List<SPCopyMigrationInfo> CreateCopyJobs(Uri[] exportObjectUris, Uri destinationUri, SPCopyMigrationOptions options)
{
throw new InvalidOperationException();
}

 

@ Microsoft: Are there any plans to implement those methods?

View solution in original post