SOLVED

CreateCopyJobs API doesn't work in SharePoint 2019

%3CLINGO-SUB%20id%3D%22lingo-sub-739473%22%20slang%3D%22en-US%22%3ECreateCopyJobs%20API%20doesn't%20work%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-739473%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20create%20SharePoint%202019%20functionality%20similar%20to%20what%20the%20Move%20and%20Copy%20Options%20in%20the%20old%20Site%20Manager%20(%22Site%20Contents%20and%20Structure)%20did%2C%20i.e.%20move%20or%20copy%20pages%20or%20documents%20to%20another%20page%2Fdocument%20library%2C%20while%20retaining%20the%20history%20of%20the%20files%2C%20updating%20the%20backward%20links%2C%20etc.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20SharePoint%20Online%20there%20are%20the%20Move%20To%20and%20Copy%20To%20buttons%20available%2C%20which%20use%20the%20CSOM%2FREST%20CreateCopyJobs%20API%20to%20accomplish%20that%20(at%20least%20the%20copy%20and%20move%20part...)%20and%20I%20was%20able%20to%20programmatically%20move%20files%20using%20that%20API.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20API%20is%20also%20available%20on-premise%2C%20but%20I%20can't%20get%20it%20to%20work.%20Not%20with%20SSOM%2C%20CSOM%20or%20REST.%3C%2FP%3E%3CP%3EIs%20it%20supposed%20to%20work%20on-premise%3F%3C%2FP%3E%3CP%3EAnd%20if%20yes%2C%20is%20there%20anything%20that%20I%20need%20to%20look%20out%20for%20to%20get%20it%20to%20work%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-739473%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-744660%22%20slang%3D%22en-US%22%3ERe%3A%20CreateCopyJobs%20API%20doesn't%20work%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-744660%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EOK...after%20decompiling%20the%202019%20version%20of%20the%20Microsoft.SharePoint.dll%20and%20checking%20the%20code%20for%20SPSite.CreateCopyJobs%20I%20now%20know%20why%20it%20doesn't%20work%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eprivate%20SPCopyMigrationInfo%20CreateCopyJobInternal(Uri%5B%5D%20exportObjectUris%2C%20Uri%20destinationUri%2C%20SPCopyMigrationOptions%20options%2C%20Guid%20correlationId%2C%20bool%3F%20runOnFE%2C%20long%20totalBytes%20%3D%200L)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Ethrow%20new%20InvalidOperationException()%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%5BObsolete(%22Use%20CreateCopyJobs%20instead%22)%5D%3CBR%20%2F%3E%5BClientCallableMethod%5D%3CBR%20%2F%3Epublic%20SPCopyMigrationInfo%20CreateCopyJob(Uri%5B%5D%20exportObjectUris%2C%20Uri%20destinationUri%2C%20SPCopyMigrationOptions%20options)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Ethrow%20new%20InvalidOperationException()%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%5BClientCallableMethod%5D%3CBR%20%2F%3Epublic%20List%3CSPCOPYMIGRATIONINFO%3E%20CreateCopyJobs(Uri%5B%5D%20exportObjectUris%2C%20Uri%20destinationUri%2C%20SPCopyMigrationOptions%20options)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Ethrow%20new%20InvalidOperationException()%3B%3CBR%20%2F%3E%7D%3C%2FSPCOPYMIGRATIONINFO%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%40%20Microsoft%3A%20Are%20there%20any%20plans%20to%20implement%20those%20methods%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New 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
Highlighted
Best Response confirmed by Tobias Heck (New 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?