Attachments API

updates the text constructor for a text attachment

PUT /api/v1/attachments/:id

Parameters

Name Description
attachable_id the id of the object this should be attached to (Lecture/Course)
attachable_type type of the object (Lecture/Course)
file a filepicker file blob {url:, filename:, mimetype:, size:, key:,container:}
text the contents of a text/html attachment
text_constructor_attributes text constructor attributes
kind the attachment kind

Request

Headers

Accept: application/json
X-Api-Token: PyvwKsbMawDV-4km65-1Zf4t7P4uCpkggQ
X-Api-Email: user-356@example.com

Route

PUT /api/v1/attachments/30

Body

{"attachable_id":48,"attachable_type":"Lecture","text_constructor_attributes":{"constructor":{"ops":[{"insert":"Hello"},{"insert":{"image":"https://exclamation.com/mark.png"},"attributes":{"width":"100"}},{"insert":"Testing..."}]}},"kind":"text"}

cURL

curl "http://localhost:3000/api/v1/attachments/30" -d '{"attachable_id":48,"attachable_type":"Lecture","text_constructor_attributes":{"constructor":{"ops":[{"insert":"Hello"},{"insert":{"image":"https://exclamation.com/mark.png"},"attributes":{"width":"100"}},{"insert":"Testing..."}]}},"kind":"text"}' -X PUT \
	-H "Accept: application/json" \
	-H "X-Api-Token: PyvwKsbMawDV-4km65-1Zf4t7P4uCpkggQ" \
	-H "X-Api-Email: user-356@example.com" \
	-H "Content-Type: application/json" \
	-H "Host: school.worksonmy.computer"

Response

Headers

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

Status

200 OK

Body

{
  "created_at": "2019-10-31T22:01:16Z",
  "code_syntax": null,
  "content_type": null,
  "audio_type": null,
  "should_be_uploaded_to_wistia?": false,
  "data": null,
  "schema": null,
  "text_constructor": {
    "id": 1,
    "constructor": {
      "ops": [
        {
          "insert": "Hello"
        },
        {
          "insert": {
            "image": "https://exclamation.com/mark.png"
          },
          "attributes": {
            "width": "100"
          }
        },
        {
          "insert": "Testing..."
        }
      ]
    },
    "attachment_id": 30,
    "school_id": 178,
    "created_at": "2019-10-31T22:01:16Z",
    "updated_at": "2019-10-31T22:01:16Z"
  },
  "full_url": "http://school.worksonmy.computer/courses/145/lectures/48",
  "url": null,
  "host_id": null,
  "source": "user",
  "kind": "text",
  "name": null,
  "host": null,
  "position": null,
  "attachable_id": 48,
  "is_published": true,
  "downloadable": true,
  "text": "This is a test thingy",
  "attachable_type": "Lecture",
  "thumbnail_url": null,
  "meta": {
    "class": "attachment",
    "url": null,
    "name": null,
    "description": "",
    "image_url": null
  },
  "embeddable": false,
  "id": 30,
  "plain_text_html": "This is a test thingy"
}