Api::V1::CommentsController API

should create a new comment

POST /api/v1/comments

Parameters

Name Description
comments comments attribute

Request

Headers

Accept: application/json
X-Api-Token: M-X_tBpozj7sLz_1KgC_2uy4Q6tkXV7y9g
X-Api-Email: user-185@example.com

Route

POST /api/v1/comments

Body

{"comments":{"school_id":92,"body":"Comment Body","user_id":187,"commentable_id":4,"commentable_type":"Attachment","attachments_attributes":{"0":{"comment_id":4,"school_id":92,"kind":"image","name":"squirrel.png","url":"https://cdn.filestackcontent.com/7ikhsaLeTDCPJaiKY4k0"}}}}

cURL

curl "http://localhost:3000/api/v1/comments" -d '{"comments":{"school_id":92,"body":"Comment Body","user_id":187,"commentable_id":4,"commentable_type":"Attachment","attachments_attributes":{"0":{"comment_id":4,"school_id":92,"kind":"image","name":"squirrel.png","url":"https://cdn.filestackcontent.com/7ikhsaLeTDCPJaiKY4k0"}}}}' -X POST \
	-H "Accept: application/json" \
	-H "X-Api-Token: M-X_tBpozj7sLz_1KgC_2uy4Q6tkXV7y9g" \
	-H "X-Api-Email: user-185@example.com" \
	-H "Content-Type: application/json" \
	-H "Host: school.worksonmy.computer"

Response

Headers

Content-Type: application/json; charset=utf-8
Content-Length: 1030

Status

201 Created

Body

{
  "created_at": "2019-10-31T21:59:51Z",
  "id": 5,
  "workflow_state": "approved",
  "ancestry": null,
  "body": "Comment Body",
  "permalink_url": "http://school.worksonmy.computer/courses/55/lectures/4/comments/5",
  "full_url": "http://school.worksonmy.computer/courses/55/lectures/4#comment_5",
  "commentable_id": 4,
  "commentable_type": "Attachment",
  "parent_id": null,
  "depth": 0,
  "user_id": 187,
  "meta": {
    "class": "comment",
    "url": null,
    "name": "5",
    "description": "",
    "image_url": null
  },
  "gravatar_url": "https://s.gravatar.com/avatar/4f26430a25289837c0e2810b3f747695?d=mm&s=70",
  "creator_name": "User Name",
  "creator_role": "owner",
  "attachments": [
    {
      "created_at": "2019-10-31T21:59:51Z",
      "id": 1,
      "comment_id": 5,
      "url": "https://cdn.filestackcontent.com/7ikhsaLeTDCPJaiKY4k0",
      "kind": "image",
      "name": "squirrel.png",
      "meta": {
        "class": "commentattachment",
        "url": null,
        "name": "squirrel.png",
        "description": "",
        "image_url": null
      },
      "thumbnail_url": "https://process.fs.teachablecdn.com/ADNupMnWyR7kCWRvm76Laz/resize=width:200,height:200/https://cdn.filestackcontent.com/7ikhsaLeTDCPJaiKY4k0"
    }
  ]
}