Skip to main content

pages/{pageid}/comments/{commentnumber}/content (PUT) (TCS)

Overview

Edit the specified comment

  • REST Method: PUT
  • Method Access: public

Uri Parameters

Name Type Description
commentnumber int identifies the comment on the page
pageid string either an integer page ID, "home", or "=" followed by a double uri-encoded page title

Query Parameters

Name Type Description
authenticate bool? Force authentication for request (default: false)

Return Codes

Name Value Description
OK 200 The request completed successfully
Bad Request 400 Invalid input parameter or request body (must be text MIME type)
Forbidden 403 Administrator access or comment author is required
Not Found 404 The requested comment could not be found

Message Format

Input: 
Content-type=text/plain

Output:

<comment id="{int}" href="{uri}">
    <page.parent id="{uri}" href="{uri}">
        <title>{text}</title> 
        <path>{text}</path> 
    </page.parent>
    <user.createdby id="{int}" href="{uri}">
        <nick>{text}</nick> 
        <username>{text}</username> 
         <email>{text}</email> 
    </user.createdby>
    <date.posted>{date}</date.posted> 
    <title>{text}</title> 
    <number>{int}</number> 
    <content type="{mimetype}" href="{uri}">{text}</content> 
    <user.editedby id="{int}" href="{uri}">
        <nick>{text}</nick> 
        <username>{text}</username> 
        <email>{text}</email> 
    </user.editedby>
    <date.edited>{date}</date.edited> 
</comment>

Implementation Notes

Use POST:pages/{pageid}/comments to create a new comment.

C# Sample: Modify a Comment

The following code example modifies the text of comment 1 on the home page:

Sample Code

Plug p = Plug.New("http://deki-hayes/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
DreamMessage msg = DreamMessage.Ok(MimeType.TEXT, "Updated comment text");
p.At("pages", "home", "comments", "1", "content").Put(msg);

Sample Response from executing Code

<comment id="1" href="http://deki-hayes/@api/deki/pages/29/comments/1">
    <page.parent id="29" href="http://deki-hayes/@api/deki/pages/29">
        <title>DekiWiki (Hayes)</title> 
        <path /> 
    </page.parent>
    <user.createdby id="1" href="http://deki-hayes/@api/deki/users/1">
        <nick>Admin</nick> 
        <username>Admin</username> 
        <email>admin@mindtouch.com</email> 
    </user.createdby>
    <date.posted>2007-08-23T09:52:07Z</date.posted> 
    <title/> 
    <number>1</number> 
    <content type="text/plain" href="http://deki-hayes/@api/deki/pages/29/comments/1/content">Updated comment text</content> 
    <user.editedby id="1" href="http://deki-hayes/@api/deki/users/1">
        <nick>Admin</nick> 
        <username>Admin</username> 
        <email>admin@mindtouch.com</email> 
    </user.editedby>
    <date.edited>2007-09-06T19:03:56Z</date.edited> 
</comment>

Implementation notes 

Add notes about requirements or config values

Curl Sample: Modify a Comment

The following command overwrites comment 1 on page "test".

Sample Code

curl -u username:password -H "Content-Type: text/plain" -T comment.txt -i http://mindtouch.address/@api/deki/pages/=test/comments/1/content

Implementation notes 

-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.
-T file
Specifies a PUT request and the file to send.
-H
Replaces or appends an HTTP header. The "Content-Type" header in this case should be set to "text/plain", as only plain text is supported in comments.
-i
Includes the HTTP response header in the output. Useful for debugging.

Example

The following curl command will replace the second comment on Jean Luc Picard's page.

jlpcomment.txt

We are the Borg. Resistance is futile.

Sample Code

curl -u admin:password -H "Content-Type: text/plain" -T jlpcomment.txt -i http://192.168.168.110/@api/deki/pages/=Jean%2520Luc%2520Picard/comments/2/content

HTTP Response Headers

HTTP/1.1 200 OK
Date: Thu, 14 Jan 2010 00:44:52 GMT
Server: Dream-HTTPAPI/1.7.2.17433
X-Deki-Site: id="default"
Content-Type: application/xml; charset=utf-8
Content-Length: 1222
Via: 1.1 dekiwiki

HTTP Response Body

Content-Type: application/xml

<?xml version="1.0"?>
<comment id="6" href="http://192.168.168.110/@api/deki/pages/51/comments/2">
  <page.parent id="51" href="http://192.168.168.110/@api/deki/pages/51?redirects=0">
    <uri.ui>http://192.168.168.110/Jean_Luc_Picard</uri.ui>
    <title>Jean Luc Picard</title>
    <path>Jean_Luc_Picard</path>
    <namespace>main</namespace>
  </page.parent>
  <user.createdby id="1" href="http://192.168.168.110/@api/deki/users/1">
    <nick>Admin</nick>
    <username>Admin</username>
    <email>melder@mindtouch.com</email>
    <hash.email>637b79dca5c8ebdc4347bccca42d3487</hash.email>
    <uri.gravatar>http://www.gravatar.com/avatar/637b79dca5c8ebdc4347bccca42d3487</uri.gravatar>
  </user.createdby>
  <date.posted>2010-01-08T23:08:35Z</date.posted>
  <title/>
  <number>2</number>
  <content type="text/plain" href="http://192.168.168.110/@api/deki/pages/51/comments/2/content">We are the Borg. Resistance is futile.</content>
  <user.editedby id="1" href="http://192.168.168.110/@api/deki/users/1">
    <nick>Admin</nick>
    <username>Admin</username>
    <email>melder@mindtouch.com</email>
    <hash.email>637b79dca5c8ebdc4347bccca42d3487</hash.email>
    <uri.gravatar>http://www.gravatar.com/avatar/637b79dca5c8ebdc4347bccca42d3487</uri.gravatar>
  </user.editedby>
  <date.edited>2010-01-14T00:44:51Z</date.edited>
</comment>

Notes

  • The page path is double encoded. In the above example, spaces in "Jean Luc Picard" are replaced with %2520.