JSON API – Record Attachments

Record Attachments

This document defines the API used for managing attachments attached to records.

Functions for uploading and downloading attachments are non-conformant with JSON API, as the current version of the API specification does not yet cater to efficiently handling byte streams.

List Attachments

GET @apiroot/records/<urlencoded eformtype>/<recordid>/attachments

Example Request

EMPTY

Example Result

{
    "data": [
        {
            "type": "attachment",
            "id": "Contract/57/attachments/banana.png",
            "attributes" : {
                "mimetype": "banana/banana",
                "size": 1234
            },
            "links": {
                "content": "@apiroot/records/Contract/57/attachments/content/banana.png"
            }
        },
        {
            "type": "attachment",
            "id": "Contract/57/attachments/folder/logo.png",
            "attributes" : {
                "mimetype": "banana/banana",
                "size": 1234
            },
            "links": {
                "content": "@apiroot/records/Contract/57/attachments/content/folder/logo.png"
            }
        }
    ]
}

Record does not exist:
404 Not Found (EMPTY)

Get Attachment Content

Non-conformant with JSON API Standard.

GET @apiroot/records/<urlencoded eformtype>/<recordid>/attachments/content/<folder>?/<filename>

Example Request

EMPTY

Example Response

BYTE STREAM

Record, folder or file does not exist:
404 Not Found (EMPTY)

Delete Attachment

DELETE @apiroot/records/<urlencoded eformtype>/<recordid>/attachments/<folder>?/<filename>

Example Request

EMPTY

Example Response

EMPTY

Record, folder or file does not exist:
404 Not Found (EMPTY)

Upload attachment

Non-conformant with JSON API Standard.

POST @apiroot/records/<urlencoded eformtype>/<recordid>/attachments/content/<folder>?/<filename>

The resultant file will have the filename dictated by the target url, content by the content of the request.

Example Request

BYTE STREAM

Example Response

Successfully uploaded:
200 Success (EMPTY)

Record, folder or file does not exist:
404 Not Found (EMPTY)

Related Articles