Comment
Comments are sub-resources of Articles only. In order to fetch comments, you need to obtain comments URL from the article resource. Comment URLs are in the form
/admin/api/site/article/<article_id>/comments.json
[
{
"body": "Hey there, i really like your blog!",
"author": "James",
"created_at": "2009/03/13 19:54:16 +0000"
}
]
Posting new comment
New comments can be posted to the same URL with POST request and providing comment data in request body. Here's an example of posting new comment with cURL:
curl -H "Content-Type: application/json" \ -d '{"comment":{"author":"Harry","author_email":"harry@mysite.com","body":"Hello!"}}' \ -X POST http://mysite.com/admin/api/site/articles/1234/comments.jsonPlease note that
Content-Type: application/json
request header is required.Here's how to post new comment with jQuery on the page:
$.ajax({ url: '/admin/api/site/articles/1234/comments.json', dataType: 'json', method: 'post', data: { comment: { author: "Harry", author_email: "harry@mysite.com", body: "Hello!" } } });