Project

General

Profile

Actions

Defect #18695

closed

Issue with multiple attachments through JSON REST API

Added by Vitaly Grin about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
High
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

Hi,
I've tried to use REST API for creating issues but found that there no way to post multiple attachments via JSON - it works for single attachment only!
When I post an "upload" JSON data as array (with brackets '[]') under "uploads" node, redmine API successfully creates an issue but without attachments - it simple ignores it. It works only if I put a single attachment straight under "uploads" section, without using an array format ('[]').


Related issues

Related to Redmine - Defect #12491: JSON api for attaching uploads only works with a single token id, not an array.Closed

Actions
Actions #1

Updated by Jean-Philippe Lang about 10 years ago

Could you post the JSON you post to create the issue with multiple attachments?

Actions #2

Updated by Jean-Philippe Lang about 10 years ago

Works fine for me with current trunk with:

{
  "issue": {
    "project_id": "1",
    "tracker_id": "1",
    "subject": "Test issue",
    "uploads": [
      {"token": "12035.d595398bbb104ed3bba0eed666785cc6", "filename": "test1.gif"},
      {"token": "12036.d595398bbb104ed3bba0eed666785cc6", "filename": "test2.gif"}
    ]
  }
}
Actions #3

Updated by Vitaly Grin about 10 years ago

Thank you for reply! Can't check it right now, will check in a few hours later. The only difference I can see for now - you are not using "upload" node as it states documentation here:
[[http://www.redmine.org/projects/redmine/wiki/Rest_api#Attaching-files]]

I.e.
"uploads": [
"upload": { "token .... }
"upload": { "token .... }
]
Is it difference for XML and JSON? Or it just docs not so updated?

UPDATE: Now I see - it's my fault. Didn't think too much about difference between arrays in XML and JSON :) Sorry about that, you can close the issue.

Actions #4

Updated by Vitaly Grin about 10 years ago

  • Status changed from New to Resolved
Actions #5

Updated by Jean-Philippe Lang about 10 years ago

  • Category set to REST API
  • Status changed from Resolved to Closed

Thanks for the feedback, I've added an example to the API guide.

Actions #6

Updated by Jean-Philippe Lang about 10 years ago

  • Related to Defect #12491: JSON api for attaching uploads only works with a single token id, not an array. added
Actions

Also available in: Atom PDF