-
Notifications
You must be signed in to change notification settings - Fork 2
RESTful API C1
annypanny edited this page Nov 29, 2016
·
13 revisions
/posts/[post_id]/comments
-
It used to get the comments in the post.
-
It returned a JSON.
-
JSON file contains:
- "count"
- "comments"
- "next"
- "query"
- "size"
- "previous"
in each "comments", it has:
- "author"
- "comment"
- "pubdate"
- "id"
- "contentType"
- "post"
in each "author", it has:
- "displayName"
- "id"
- "host"
- "url"
- "github"
Method:
GET
Example:
GET /posts/e0420969-e020-4bdb-8285-3ea5d0f97878/comments/
HTTP 200 OK
Allow: GET, POST, OPTIONS
Content-Type: application/json
Vary: Accept
{
"count": 1,
"comments": [
{
"author": {
"displayName": "Jiafeng Wu",
"id": "eb572e7b-7856-468b-bfdf-9b6388f9165c",
"host": "http://socialnets404.herokuapp.com/",
"url": "http://socialnets404.herokuapp.com/author/eb572e7b-7856-468b-bfdf-9b6388f9165c",
"github": "jiafengwu0301"
},
"comment": "blah blah blah",
"pubdate": "2016-11-28T21:21:32.476742Z",
"id": "a94416b4-c6bd-4dac-8fc2-fbf8886c9396",
"contentType": "text/plain",
"post": "http://socialnets404.herokuapp.com/posts/e0420969-e020-4bdb-8285-3ea5d0f97878"
}
],
"next": null,
"query": "comments",
"size": 100,
"previous": null
}
- Also it could make a new comments for the given post_id on the server.
- After the user add info of comments, it send a JSON file to the server, server return a message.
- JSON file contains:
- "displayName"
- "id"
- "host"
- "url"
- "github"
- "comment"
- "contentType"
- "post"
Method:
POST
Example:
POST /posts/e0420969-e020-4bdb-8285-3ea5d0f97878/comments/
HTTP 200 OK
Allow: GET, POST, OPTIONS
Content-Type: application/json
Vary: Accept