Overview
You can use this request to search for and return a paged list of comments posted to a specific node.
Information
You can use the following parameters in your retrieve a node's comments list request:
Paging and Sorting: page, pageSize, sort
Search: q, type, lang
Projection: include, exclude, includeOnly
Other options: wrap, v1
Permissions & Notes:
-
You must have the View the question page and View answers in the question page permissions under Anonymous Roles in the Advanced Editor.
-
With the includeOnly parameter set to id and name (/services/v2/node/[nodeID]/comment.json?includeOnly=id,name) to the AnswerHub REST API.
- We added this request in version 1.6.3.
The Example below is retrieving a list of comments for a question node.
RETRIEVE QUESTION NODE ID: Make a GET request called Retrieve Questions List FIRST. Then add that nodeId to your request to retrieve a list of comments posted.
A GET retrieve a list of comments posted to a node request to retrieve a list of comments for a node (nodeId: 861 - In this case it is the question node) sent to https://apidocs.cloud.answerhub.com using a human-readable Username/Password (answerhub/test123) would look like this:
- cURL
curl
-u answerhub:test123
-H "Accept: application/json"
-H "Content-type: application/json"
-X GET "https://apidocs.cloud.answerhub.com/services/v2/node/861/comment.json"
- Sample Formatted JSON Response
{
"name": "",
"sort": "active",
"page": 1,
"pageSize": 15,
"pageCount": 1,
"listCount": 1,
"totalCount": 1,
"sorts": [
"active",
"newest",
"hottest",
"votes",
"viewCount",
"usedCount",
"answerCount",
"answerCountAsc",
"commentCount",
"favoriteCount",
"followers",
"reportCount"
],
"list": [
{
"id": 905,
"type": "comment",
"creationDate": 1551454306000,
"creationDateFormatted": "03/01/2019 03:31 PM",
"body": "<div \"fr-view clearfix\"><p>this is a test comment on the post</p></div>",
"bodyAsHTML": "<div \"fr-view clearfix\"><p>this is a test comment on the post</p></div>",
"author": {
"id": 112,
"username": "ricks",
"reputation": 1
},
"lastEditedAction": 1285,
"activeRevisionId": 908,
"revisionIds": [
908
],
"lastActiveUserId": 112,
"lastActiveDate": 1551454306000,
"originalParentId": 861,
"attachments": [],
"childrenIds": [],
"commentIds": [],
"marked": false,
"topics": [],
"containerIds": [],
"wiki": false,
"score": 0,
"depth": 0,
"viewCount": 0,
"upVoteCount": 0,
"downVoteCount": 0,
"nodeStates": []
}
]
}
Priyanka Bhotika
Comments