Skip to main content

Comments

Comments

List Comments

  • Authentication: Optional
GET /api/v1/posts/{number}/comments

Parameters

NameTypeDescription
numbernumberRequired. The number of the post to get comments from.

Example

GET <baseURL>/api/v1/posts/47/comments

Response

[
{
"id":67,
"content":"Sounds good, right?",
"createdAt":"2017-07-26T04:15:22.72261Z",
"user":{
"id":54,
"name":"Michael Jackson",
"role":"visitor"
}
},
{
"id":68,
"content":"Definitely. Just do it!",
"createdAt":"2017-07-26T06:49:03.951383Z",
"user":{
"id":23,
"name":"Darth Vader",
"role":"visitor"
},
"editedAt":"2018-09-29T17:37:59.516909Z",
"editedBy":{
"id":1,
"name":"Jon Snow",
"role":"administrator"
}
}
]

Get a Comment

  • Authentication: Optional
GET /api/v1/posts/{number}/comments/{id}

Parameters

NameTypeDescription
numbernumberRequired. The number of the post to retrieve.
idnumberRequired. The id of the comment to be retrieved.

Example

GET <baseURL>/api/v1/posts/47/comments/68

Response

200 OK
---
{
"id":68,
"content":"Definitely. Just do it!",
"createdAt":"2017-07-26T06:49:03.951383Z",
"user":{
"id":23,
"name":"Darth Vader",
"role":"visitor"
},
"editedAt":"2018-09-29T17:37:59.516909Z",
"editedBy":{
"id":1,
"name":"Jon Snow",
"role":"administrator"
}
}

Add a Comment

  • Authentication: Required
POST /api/v1/posts/{number}/comments

Parameters

NameTypeDescription
numbernumberRequired. The number of the post to add the comment.
contentstringRequired. The content of the comment.

Example

POST <baseURL>/api/v1/posts/47/comments
---
{
"content": "Agreed, we'll soon need to act on this"
}

Response

200 OK
---
{
"id":5675
}

Edit a Comment

  • Authentication: Required
  • Required Role: Collaborator or Administrator.
PUT /api/v1/posts/{number}/comments/{id}

Parameters

NameTypeDescription
numbernumberRequired. The number of the post that has given comment.
idnumberRequired. The id of the comment to be edited.
contentstringRequired. The new content of the comment.

Example

POST <baseURL>/api/v1/posts/47/comments/5675
---
{
"content": "Agreed, we need to act on this as soon as possible"
}

Response

200 OK
---
{}

Delete a Comment

  • Authentication: Required
  • Required Role: Collaborator or Administrator.
DELETE /api/v1/posts/{number}/comments/{id}

Parameters

NameTypeDescription
numbernumberRequired. The number of the post that has given comment.
idnumberRequired. The id of the comment to be edited.

Example

DELETE <baseURL>/api/v1/posts/47/comments/5675

Response

200 OK
---
{}