Defect #18695
closedIssue with multiple attachments through JSON REST API
0%
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
Updated by Jean-Philippe Lang almost 10 years ago
Could you post the JSON you post to create the issue with multiple attachments?
Updated by Jean-Philippe Lang almost 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"} ] } }
Updated by Vitaly Grin almost 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.
Updated by Jean-Philippe Lang almost 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.
Updated by Jean-Philippe Lang almost 10 years ago
- Related to Defect #12491: JSON api for attaching uploads only works with a single token id, not an array. added