Attachments API
Files can be uploaded to Aha! as a sub-resource on any resource that supports them. These resources support attachments:
- Record descriptions (the description of a feature, requirement, etc.)
- Comments
- To-dos
- Custom note fields
The format of an attachment is either a multipart/form-data
upload with
the input name attachment[data]
or a JSON payload pointing to an URL link:
{
"attachment": {
"file_url": "http://www.aha.io/",
"content_type": "text/html",
"file_name": "home_page.html"
}
}
Reject duplicate attachments
POST /api/v1/notes/:note_id/attachments
If the "If-None-Match" header is passed, Aha! will check the file's MD5 against other files uploaded that also used the If-None-Match header. If a file shares the same file size, name, and md5, a new attachment will not be created, and an HTTP 412 status code will be returned.
Name | Description |
---|---|
note_id * | Numeric ID of the record description for which the attachment should be created |
Example request
POST /api/v1/notes/793547626/attachments
Example CURL command
curl "/api/v1/notes/793547626/attachments" -F "attachment[data]=@sample_plain_text.txt" -X POST \
-H "Authorization: Bearer 15b60d42d4bc417284a246ced6877b0bf13fb4aca415f7b55f7006bc3694a8ab" \
-H "Accept: application/json" \
-H "If-None-Match: sample_etag"
Request
authorization: Bearer 15b60d42d4bc417284a246ced6877b0bf13fb4aca415f7b55f7006bc3694a8ab
contentType: multipart/form-data; boundary=----------XnJLe9ZIbbGUYtzPQJ16u1
accept: application/json
Request body
------------XnJLe9ZIbbGUYtzPQJ16u1 content-disposition: form-data; name="attachment[data]"; filename="sample_plain_text.txt" content-type: text/plain content-length: 27 [uploaded data] ------------XnJLe9ZIbbGUYtzPQJ16u1--
Response
Status: 412 Precondition Failed
contentType: application/json; charset=utf-8
Response body