Uploading attachments (via JSON)

attachment
rest api
tasks

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"}
    ]
  }
}

Try Easy Redmine in 30 days free trial

Full features, SSL protected, daily backups, in your geolocation