Defect #18695
closed
Issue with multiple attachments through JSON REST API
Added by Vitaly Grin over 9 years ago.
Updated over 9 years ago.
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 ('[]').
Could you post the JSON you post to create the issue with multiple attachments?
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"}
]
}
}
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.
- Status changed from New to Resolved
- Category set to REST API
- Status changed from Resolved to Closed
Thanks for the feedback, I've added an example to the API guide.
- Related to Defect #12491: JSON api for attaching uploads only works with a single token id, not an array. added
Also available in: Atom
PDF