Skip to content

API Doc: Comments Access

Ryan Satyabrata edited this page Nov 30, 2016 · 8 revisions

GET api/posts/{POST_ID}/comments
POST api/posts/{POST_ID}/comments

GET api/posts/{POST_ID}/comments

Used to get all the comments of the post. Used with HTTP GET, {POST_ID} is the UUID of the post, which is required.
One can add pagination query strings.

It returns a JSON object which contains the number of comments, and how many per page, the next and previous page if exist, and the comment.
The comment itself contains the author with it's information like display name, author uuid etc., the comment, the content type, the time of creation, and the comment uuid.

Here is an example:
GET api/posts/92c4cbd3-2e36-4b53-a66b-01bff793e62d/comments HTTP/1.1
Header: Value

200 Ok ...
{
	"query": "comments",
        # comments about the post
        # returns a maximum number of comments
        # A list of posts
    	"count": 1023,
    	"size": 50,
    	# Does not return next if last page
        "next": "http://service/posts/{post_id}/comments?page=5",
    	# Does not return previous if page is 0.
    	"previous": "http://service/posts/{post_id}/comments?page=3",
        "comments":[ {
		"author":{
		    # ID of the Author (UUID)
			"id":"de305d54-75b4-431b-adb2-eb6b9e546013",
			"host":"http://127.0.0.1:5454/",
			"displayName":"Greg Johnson",
			# url to the authors information
			"url":"http://127.0.0.1:5454/author
				/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
			# HATEOS url for Github API
			"github": "http://github.com/gjohnson"
		},
		"comment":"Sick Olde English",
		"contentType":"text/x-markdown",
		# ISO 8601 TIMESTAMP
		"pubDate":"2015-03-09T13:07:04+00:00",
		# ID of the Comment (UUID)
		"guid":"de305d54-75b4-431b-adb2-eb6b9e546013"
	}, {
		"author":{
		    # ID of the Author (UUID)
			"id":"ab405d54-56d7-431b-adb2-eb6b8e165314",
			"host":"http://127.0.0.1:5454/",
			"displayName":"Leeroy Jenkins",
			# url to the authors information
			"url":"http://127.0.0.1:5454/author
				/9ab17f29c12e8f97bcbbd34cc908f1baba40658e",
			# HATEOS url for Github API
			"github": "http://github.com/leeeroy"
		},
		"comment":"Leeeeeeeeeeeeeroy!",
		"contentType":"text/x-markdown",
		# ISO 8601 TIMESTAMP
		"pubDate":"2015-03-09T14:15:04+00:00",
		# ID of the Comment (UUID)
		"guid":"ab405d54-56d7-431b-adb2-eb6b8e165314"
	}]
}

POST api/posts/{POST_ID}/comments

Used to POST a comments to that post. Used with HTTP POST, {POST_ID} is the UUID of the post, which is required.

It returns a JSON object which says if the comment was a success or not.

Here is an example:
POST api/posts/92c4cbd3-2e36-4b53-a66b-01bff793e62d/comments HTTP/1.1
{
	"query": "addComment",
	"post":"http://whereitcamefrom.com/posts/zzzzz",
	"comment":{
	    "author":{
	           # ID of the Author (UUID)
		   "id":"de305d54-75b4-431b-adb2-eb6b9e546013",
		   "host":"http://127.0.0.1:5454/",
		   "displayName":"Greg Johnson",
		   # url to the authors information
		   "url":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
		   # HATEOS url for Github API
		   "github": "http://github.com/gjohnson"
	   },
	   "comment":"Sick Olde English",
	   "contentType":"text/x-markdown",
	   # ISO 8601 TIMESTAMP
	   "published":"2015-03-09T13:07:04+00:00",
	   # ID of the Comment (UUID)
	   "guid":"de305d54-75b4-431b-adb2-eb6b9e546013"
	}
}

Responds with 
200 OK
{
	"query": "addComment",
        "success":true,
        "message":"Comment Added"
}

or if they don't have the visibility
403 Forbidden
{
	"query": "addComment",
        "success":false,
        "message":"Comment not allowed"
}

Clone this wiki locally