Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Specify custom order of fields returned from JIRA REST API using cURL

Morgan Goodrich
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 12, 2018

Hi,

I want to be able to specify the order of the fields returned from my JQL query. Some fields are custom fields and by default, they return in order of ascending custom field ID, which I don't want. I'm trying to output this to a spreadsheet, so I would like certain fields containing multiple entries to output to the last column, which avoids shifting all the other columns around.

My command is:

$ (curl -u user:'password' -X GET 'url/rest/api/latest/search?jql=project=KEY&maxResults=200&fields=summary,customfield_11003,customfield_11001' | sed 's/{"expand":/\\\n/g') > output.csv

I want this to output:

summary, customfield_11003,customfield_11001 in that order, i.e., not ascending by field ID.

Instead it outputs:

summary,customfield_11001,customfield_11003.

I've tried simply inputting the desired order, using the order by command, using various delimiters, and various combinations of the field command. I'd like to avoid renaming the custom fields, as that is not a viable solution for our team.

Any help is appreciated - thanks!

1 answer

1 accepted

1 vote
Answer accepted
Alexey Matveev
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.
June 12, 2018

Hello,

You can not specify an order. You should parse JSON programmatically and produce any order you need.

Suggest an answer

Log in or Sign up to answer