Copying a File

You can use the copyFile call to copy a file.

Sample URL

https://hostname:port/context/rest/v2/documents/copyFile/{id}

Method

POST

Parameters

Parameter Description
targetId Optional.

The target folder document ID.

If the target folder is a top root folder, do not send this parameter.

id The source document ID.
sourcePath Optional.

If the id parameter is not presented in the URL, this field is required. If the id parameter is presented, this parameter will be ignored.

This parameter points to a source file, for example: sourcePath=/Presentation/Slides.ppt. Here, Presentation is a folder name and Slide.ppt is a file name.

targetPath Optional.

Instead of the targetId parameter, you can send the targetPath parameter, for example, targetPath=/Presentation, and then the file will be copied into the Presentation folder.

Response

HTTP Status Code Description
200 The call is executed successfully.

The format of the response is {"source":{<sourceDocument>},"target":{<copiedDocument>}}.

Example:

{"source":{"dateModified":1405467631090,"users":"E:user1:A:user2;O:user3:A:user3","type":"F","lastUpdatedOn":1405467631070,"size":561276,"id":"147F00000442","createdOn":1405467619070,"parentId":"145R00001F46","latestVersion":3,"shareId":"145R00001F46","createdBy":"user3","name":"Lighthouse.jpg","lastUpdatedBy":"user3"},"target":{"dateModified":1405467631090,"users":"O:user3:A:user3","type":"F","lastUpdatedOn":1405700286158,"size":561276,"id":"147I00000010","createdOn":1405700286158,"parentId":"143Q00000037","latestVersion":1,"shareId":"143Q00000037","createdBy":"user3","name":"Lighthouse-new Name.jpg","lastUpdatedBy":"user3"}}

400 An error occurs.

{"message":"There is duplicated file or folder name in the target folder!"}