response of REST API

lars_reus May 12, 2023

Hello, 

 

when i call the JIRA REST API to create an issue

rest/api/2/issue

i get the responst in JSON format.

 

when attaching a File to that issue

rest/api/2/issue/xxx/attachments

i get the response in JSON format, but with surrounding "[]"-braces. 

 

why that?

best regards

Lars

 

Info: 

"version""8.12.3"

2 answers

0 votes
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2023

Because that's the expected behaviour, as per the documentation:

POST /rest/api/2/issue/{issueIdOrKey}/attachments

Add one or more attachments to an issue.

Since you can attach 1 or more, the response has be an array of 1 or more objects, which is shown in the example response provided in the documentation:

[
{
"self": "http://www.example.com/jira/rest/api/2.0/attachments/10000",
"filename": "picture.jpg",
<blah blah>,
},
{
"self": "http://www.example.com/jira/rest/api/2.0/attachments/10001",
"filename": "dbeuglog.txt",
<blah blah>
}
]
lars_reus May 14, 2023

Hello David,

thank you for the answer, that makes sense..

Lars

Like David Bakkers likes this
0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2023

Are you asking us why we developed an endpoint to return a JSON array instead of what you expect, a JSON object?

We didn't. You're asking us design questions, this is a community, not an atlassian dev hub / coffee room.

Suggest an answer

Log in or Sign up to answer