Was this page helpful?

Copy an attachment

    Description of the code samples

    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 page helpful?
    Tag page
    Viewing 2 of 2 comments: view all
    I have tried it but it gives me following out put.

    405allowed methods are DELETE, GET, HEAD, LOCK, OPTIONS, PUT

    please help me what is the wrong in following code

    curl -u username:password -d "" -i 'http://mindt_url/@api/deki/files/97/copy?to=334

    Thanks edited 03:24, 29 Mar 2011
    Posted 03:23, 29 Mar 2011
    Any update to this documentation? I also get the same error. Thanks!
    Posted 06:36, 6 Jul 2011
    Viewing 2 of 2 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by