Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillipharding/499d81b2e7e987160854cc88698c171a to your computer and use it in GitHub Desktop.
Save phillipharding/499d81b2e7e987160854cc88698c171a to your computer and use it in GitHub Desktop.
References:
- https://gist.github.com/zplume/9f4c1a658517802701deff3473f23a60
- https://gist.github.com/zplume/21248c3a8a5f840a366722442cf9ee97
- https://blog.velingeorgiev.com/createcopyjobs-api-copy-move-SharePoint-files-folders
- See also: https://gist.github.com/zplume/9f4c1a658517802701deff3473f23a60
"NameConflictBehavior":0 = Fail
"NameConflictBehavior":1 = Replace
"NameConflictBehavior":2 = Rename at destination (Keep Both)
Based on similar bejaviour at: https://docs.microsoft.com/en-us/graph/api/resources/driveitem?view=graph-rest-1.0
"IsMoveMode": true moves the file, false cpoies the file
"AllowSchemaMismatch": allows file move with missing or mismatched field definition on the destination list for source field
"IgnoreVersionHistory": ignores version history when moving the file and will create version (1.0) at the target location
POST https://platinumdogsconsulting.sharepoint.com/sites/hubsitetest/_api/site/CreateCopyJobs
HEADERS
{
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
X-RequestDigest: <<site form digest>>
}
BODY
{
"exportObjectUris":[
"https://platinumdogsconsulting.sharepoint.com/sites/hubsitetest/Shared%20Documents/Folder%202"
],
"destinationUri":"https://platinumdogsconsulting.sharepoint.com/teams/hubjoinedsite01/Archive",
"options":{
"IgnoreVersionHistory":true,
"IsMoveMode":true,
"AllowSchemaMismatch":true,
"NameConflictBehavior":2
}
}
RESPONSE
{
"d": {
"CreateCopyJobs": {
"__metadata": {
"type": "Collection(SP.CopyMigrationInfo)"
},
"results": [
{
"EncryptionKey": "6YIOwbP9/TSLiw6D0H+mvsiRbgjSvJLs5L28Pfx/0BQ=",
"JobId": "d0a42793-f995-4ce2-b0fb-cc3c0e819e19",
"JobQueueUri": "https://spodb1am1m025pr.queue.core.windows.net:443/1217pq20190522-d6b14cff5d28495b83e38b66e3c96c60?sv=2017-07-29&sig=PZQnN9zfInHrH8fbJkm7r77FeWJePHFyb4K6Q3GMmuA%3D&st=2019-05-21T07%3A00%3A00Z&se=2019-06-12T07%3A00%3A00Z&sp=rap",
"SourceListItemUniqueIds": {
"__metadata": {
"type": "Collection(Edm.Guid)"
},
"results": [
"208875e4-2659-433d-acd8-4d77fc76e1ef"
]
}
}
]
}
}
}
@phillipharding
Copy link
Author

References:

Options

 NameConflictBehavior: 0 = Fail
 NameConflictBehavior: 1 = Replace
 NameConflictBehavior: 2 = Rename at destination (Keep Both)

Based on similar behaviour at: (https://docs.microsoft.com/en-us/graph/api/resources/driveitem?view=graph-rest-1.0)

 IsMoveMode: true|false - true moves the file, false copies the file
 AllowSchemaMismatch: true|false - allows file move with missing or mismatched field definition on the destination list for source field
 IgnoreVersionHistory: true|false - ignores version history when moving the file and will create version (1.0) at the target location

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment