References
- (https://s-kainet.github.io/sp-rest-explorer/#/_api/SP.MoveCopyUtil.CopyFileByPath)
- (https://gist.github.com/zplume/9f4c1a658517802701deff3473f23a60)
- (https://blog.velingeorgiev.com/createcopyjobs-api-copy-move-SharePoint-files-folders)
When overwrite
is true
and KeepBoth
is true
the destination file is overwritten.
When overwrite
is true
and KeepBoth
is false
, or
When overwrite
is false
and KeepBoth
is false
the destination file is not overwritten and a new file with a duplicate avoiding filename is created - i.e. a number is appended to the filename to avoid a duplicate.
REQUEST
POST https://platinumdogsconsulting.sharepoint.com/sites/hubsitetest/_api/SP.MoveCopyUtil.CopyFileByPath()
HEADERS
{
Accept: application/json;odata=nometadata
Content-Type: application/json;odata=nometadata
X-RequestDigest:{{formDigest}}
}
BODY
{
"srcPath": {
"DecodedUrl": "https://platinumdogsconsulting.sharepoint.com/sites/hubsitetest/EdmsTestDocLib/Folder 1/Folder 1-1/downhill-freestanding-718824-contract-135.docx"
},
"destPath": {
"DecodedUrl": "https://platinumdogsconsulting.sharepoint.com/sites/hubsitetest/Edwards Active Documents/Folder 01/downhill-freestanding-718824-contract-135.docx"
},
"overwrite": true,
"options": {
"KeepBoth": false,
"ResetAuthorAndCreatedOnCopy": false,
"ShouldBypassSharedLocks": true
}
}
RESPONSE
HTTP STATUS CODE: 200
BODY
{
"odata.null": true
}
RESPONSE WHEN A DUPLICATE FILE IS PRESENT AT DESTINATION
When overwrite
is false
and KeepBoth
is false
HTTP STATUS CODE: 400
BODY
{
"odata.error": {
"code": "-2130575257, Microsoft.SharePoint.SPException",
"message": {
"lang": "en-US",
"value": "The destination file already exists."
}
}
}