Skip to content
gosiawolniewicz edited this page Mar 17, 2020 · 4 revisions

Comments API

Comments API is responsible for collecting and managing user comments.

Creating comments

Send following JSON message in order to create comment:

{ "text":"", "authorName":"", "resource" : "", "parentHash":"" } 

When obtaining comment from service the following JSON will be send. _links section contains links to this, parent and response messages.

{ "text" : "", "authorName" : "", "parentHash" : "", "resource" : "", "created" : "", "modified" : "", "hash" : "", "voteUp" : , "voteDown" : , "_links" : { "self" : { "href" : "http://beta.rohub.org/comments/api/comments/{comment_id}" }, "comment" : { "href" : "http://beta.rohub.org/comments/api/comments/{comment_id}" }, "parent" : { "href" : "http://beta.rohub.org/comments/api/comments/{comment_id}/parent" }, "responses" : { "href" : "http://beta.rohub.org/comments/api/comments/{comment_id}/responses" } }

In order to create comment, comment JSON message must by send in request body. POST -H "Content-Type: application/json" /api/comments

Getting comments

Getting all comments

 
GET -H "Accept: application/json" /api/comments 3.3 Get all comments with pagination GET -H "Accept: application/json" /api/comments{?page,size,sort} 

Getting comment

 
GET -H "Accept: application/json" /api/comments/{comment_id} 3.3 Get parent comment GET -H "Accept: application/json" /api/comments/{comment_id}/parent 3.3 Get get responses for this comment GET -H "Accept: application/json" /api/comments/{comment_id}/responses 

Get first level comments associated with particular resource, the one without parent comment

GET -H "Accept: application/json" /api/comments/search/resource{?res,page,size,sort}

Getting first level comments

Get first level comments associated with particular ro, the one without parent comment

GET -H "Accept: application/json" /api/comments/search/ro{?ro,page,size,sort} 

Voting for comments

Vote comment UP

 
PUT -H "Accept: application/json" /api/comments/{comment_id}/voteup

Vote comment DOWN

 
PUT -H "Accept: application/json" /api/comments/{comment_id}/votedown 3.8 Get thread GET -H "Accept: application/json" /api/comments/{comment_id}/thread

Updating comments

New comment text must be send as JSON in request body

 
PUT -H "Content-Type: application/json" http://beta.rohub.org/comments/api/comments/{id} eg: curl -v -X PUT -H "Content-Type: application/json" --data-asci "{"text":"it must have text"}" http://beta.rohub.org/comments/api/comments/71 

Deleting comments

Deleting comment

DELETE http://beta.rohub.org/comments/api/comments/{id}/

Clone this wiki locally