Skip to main content

pages/{pageid}/comments/{commentnumber} (GET)

Overview

Retrieve a comment and metadata

  • REST Method: GET
  • Method Access: public

Uri Parameters

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

Query Parameters

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

Return Codes

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

Message Format

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> 
    <user.deletedby id="{int}" href="{uri}">
        <nick>{text}</nick> 
        <username>{text}</username> 
        <email>{text}</email> 
    </user.deletedby>
    <date.deleted>{date}</date.deleted> 
</comment>

Implementation Notes

The user.deletedby and date.deleted elements only exist if the comment has been deleted.

Use POST:pages/{pageid}/comments to add new comments to the page.

C# Code Sample: Retrieve a Comment

The following code example retrieves the first comment on the home page:

Sample Code

Plug p = Plug.New("http://deki-hayes/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
p.At("pages", "home", "comments", "1").Get();

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">Comment text</content> 
</comment>

Implementation notes 

Add notes about requirements or config values

Curl Code Sample: Retrieve a Comment

The following command retrieves a specific comment (commentnumber = 1) made on page "foo":

Sample Code

curl -u username:password -i http://mindtouch.address/@api/deki/pages/=foo/comments/1

Sample Response from executing Code

<comment id="22" href="http://192.168.59.128/@api/deki/pages/596/comments/1">
  <page.parent id="596" href="http://192.168.59.128/@api/deki/pages/596?redirects=0">
    <uri.ui>http://192.168.59.128/Gotham</uri.ui>
    <title>Gotham</title>
    <path>Gotham</path>
    <namespace>main</namespace>
  </page.parent>
  <user.createdby id="1" href="http://192.168.59.128/@api/deki/users/1">
    <nick>Admin</nick>
    <username>Admin</username>
    <email hidden="true"/>
    <hash.email>64e1b8d34f425d19e1ee2ea7236d3028</hash.email>
    <uri.gravatar>http://www.gravatar.com/avatar/64e1b8d34f425d19e1ee2ea7236d3028</uri.gravatar>
  </user.createdby>
  <date.posted>2010-01-28T20:13:13Z</date.posted>
  <title/>
  <number>1</number>
  <content type="text/plain; charset=utf-8" href="http://192.168.59.128/@api/deki/pages/596/comments/1/content">I am the Batman</content>
</comment>

Implementation notes 

curl flags

-u
Provides external user authentication. Note that if anonymous access is available and authentication is not forced, this flag may be omitted.
-i
Outputs the HTTP response headers. Useful for debugging.

Pages comments

To view a list of all comments within a page, follow the instructions here.
  • Was this article helpful?