Skip to main content
NICE CXone Expert

Scheduled CxOne Expert Maintenance - Oct 26th 11:59 pm PT - Learn More

Expert Success Center

files/{fileid}/copy (POST)

Overview

Copy an attachment from one page to another and/or change the filename

  • REST Method: POST
  • Method Access: public

Uri Parameters

Name Type Description
fileid int identifies a file by ID

Query Parameters

Name Type Description
authenticate bool? Force authentication for request (default: false)
name string? new filename
to string? page id of target page

Return Codes

Name Value Description
OK 200 The request completed successfully
Bad Request 400 Invalid input parameter or request body
Forbidden 403 Update access to the page is required
Not Found 404 Requested file could not be found

Implementation Notes

A file cannot be copied to a template page or a destination page that already contains a file with the same name.

Curl Code Sample: Copy an Attachment

The first example copies file with id 20 to page with id 213. The second example does the same except it renames the newly created file to "newname.txt"

Sample Code (Copy)

curl -u username:password -d "" -i http://mindtouch.address/@api/deki/files/20/copy?to=213

Sample Code (Copy and rename)

curl -u username:password -d "" -i "http://mindtouch.address/@api/deki/files/20/copy?to=213&name=newname.txt"

Implementation notes 

curl flags

-u:
Basic HTTP authentication. Sends a username and password to server so it can verify whether a user is of privilege to perform specific operation.
-d
Specifies a POST request. The parentheses ("") imply no data, since no external data is required to complete the operation.
-i
Includes the HTTP response header in the output. Useful for debugging.

Example

In this example we will copy an attachment (id: 20) to the destination page (id: 456) and rename the file to "hello.txt".

Sample Code

curl -u admin:password -d "" -i "http://mindtouch.address/@api/deki/files/20/copy?to=456&name=hello.odt"

HTTP Response Headers

HTTP/1.1 200 OK
Date: Wed, 16 Mar 2011 23:08:44 GMT
Server: Dream-HTTPAPI/2.3.0.113 Microsoft-HTTPAPI/2.0
Content-Length: 997
Content-Type: application/xml; charset=utf-8
X-Data-Stats: request-time-ms=119; mysql-queries=24; mysql-time-ms=55;
X-Deki-Site: id="default"
Via: 1.1 mindtouch

HTTP Response Body

Content-Type: application/xml

<file id="31" revision="1" href="http://devvm/@api/deki/files/31/info">
    <filename>hello2.odt</filename>
        <description/>
            <contents type="application/vnd.oasis.opendocument.text" size="29036" href="http://devvm/@api/deki/files/31/=hello2.odt"/>
        <date.created>2011-03-16T23:11:47Z</date.created>
        <user.createdby id="1" href="http://devvm/@api/deki/users/1">
        <nick>Admin</nick>
        <username>Admin</username>
        <fullname/>
            <email>noreply@mindtouch.com</email>
            <hash.email></hash.email>
        </user.createdby>
    <revisions count="1" totalcount="1" href="http://devvm/@api/deki/files/31/revisions"/>
    <page.parent id="456" revision="1" href="http://devvm/@api/deki/pages/456?redirects=0">
    <uri.ui>http://devvm/talk17</uri.ui>
    <title>talktest</title>
    <path type="custom">talk17</path>
    <namespace>main</namespace>
    </page.parent>
</file>


 

  • Was this article helpful?