Uploading attachments (via JSON)

Author: System Administrator Displayed: 11734
Created: 02/09/2015 Updated: 10/05/2018
Version: 8
MoreLess

Uploading attachments (via JSON)

This tutorial explains how to upload some attachments to a task via JSON using the REST API.

JSON Example

First, upload your file:

POST /uploads.json
Content-Type: application/octet-stream
...
(request body is the file content)

# 201 response
{"upload":{"token":"7167.ed1ccdb093229ca1bd0b043618d88743"}}

Then create the issue using the upload token:

POST /issues.json
{
  "issue": {
    "project_id": "1",
    "subject": "Creating an issue with a uploaded file",
    "uploads": [
      {"token": "7167.ed1ccdb093229ca1bd0b043618d88743", "filename": "image.png", "content_type": "image/png"}
    ]
  }
}

You can also upload multiple files (by doing multiple POST requests to /uploads.json), then create an issue with multiple attachments:

POST /issues.json
{
  "issue": {
    "project_id": "1",
    "subject": "Creating an issue with a uploaded file",
    "uploads": [
      {"token": "7167.ed1ccdb093229ca1bd0b043618d88743", "filename": "image1.png", "content_type": "image/png"},
      {"token": "7168.d595398bbb104ed3bba0eed666785cc6", "filename": "image2.png", "content_type": "image/png"}
    ]
  }
}
Add picture from clipboard