Skip to main content

pages/{pageid}/comments (POST) (TCS)


Post a new comment to a page

  • REST Method: POST
  • Method Access: public

Uri Parameters

Name Type Description
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)
title string? Title for comment

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 Update access to the page is required
Not Found 404 The requested page could not be found

Message Format



<comment id="{int}" href="{uri}">
    <page.parent id="{uri}" href="{uri}">
    <user.createdby id="{int}" href="{uri}">
    <content type="{mimetype}" href="{uri}">{text}</content> 

Implementation Notes

Use PUT:pages/{pageid}/comments/{commentnumber}/content to update an existing comment.

C# Code Sample: Post Comment to Homepage

The following code example creates a new comment on the home page


Sample Code

Plug p = Plug.New("http://deki-hayes/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
DreamMessa msg = DreamMessage.Ok(MimeType.TEXT, "Comment text");
p.At("pages", "home", "comments").Post(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 /> 
    <user.createdby id="1" href="http://deki-hayes/@api/deki/users/1">
    <content type="text/plain" href="http://deki-hayes/@api/deki/pages/29/comments/1/content">Comment text</content>

Curl Code Sample: Posting a Comment

The following curl command will post a comment containing the data in "comment.txt" on page "test".

Sample Code

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

Implementation notes 

curl flags

Basic HTTP authentication. Sends a username and password to server so it can verify whether a user is of privilege to perform specific operation.
Adds a header or modifies an existing one. When posting comments, the Content-Type must be set to text/plain.
-d @file
Specifies a POST request and the file to send.
Includes the HTTP response header in the output. Useful for debugging.



Spock shares his thoughts on Jean Luc Picard's page. His comment is documented in line.txt.


Content-Type: text/plain

This is highly illogical.

Sample Code

curl -u spock:spock -H "Content-Type: text/plain" -d @line.txt -i http://mindtouch.address/@api/deki/pages/=Jean%2520Luc%2520Picard/comments

HTTP Response Headers

HTTP/1.1 200 OK
Date: Wed, 06 Jan 2010 23:51:09 GMT
Server: Dream-HTTPAPI/
X-Deki-Site: id="default"
Content-Type: application/xml; charset=utf-8
Content-Length: 844
Via: 1.1 dekiwiki

HTTP Response Body

Content-Type: application/xml

<?xml version="1.0"?>
<comment id="5" href="">
  <page.parent id="51" href="">
    <title>Jean Luc Picard</title>
  <user.createdby id="5" href="">
  <content type="text/plain" href="">This is highly illogical.</content>


  • The username:password combination in this case is spock:spock.
  • The page path is double encoded. In the above example, spaces in "Jean Luc Picard" are replaced with %2520.
  • Was this article helpful?