Jira expression REST API to get all issue data

Hello guys,

At the moment, we’re using the search call of the REST API to get the issues for a JQL and all its data (all fields and the changelog too in some cases).

At the Atlas Camp, @raimonds.simanovskis from eazyBI told us in his talk that we can try the Jira expressions REST API to get issue data instead using the search API for performance purposes. The main reason is that you can ask for 1000 results at the same with Jira expressions time and only 100 with the search API and this is so important for a big JQL.

I’ve been playing a little with Jira expression to know if it fits our necessities but I have 2 main questions at the moment:

  • Is there a possibility to get all issue fields? What will be the Jira expression for it? By default, I can get the issue with some basic fields (id, key, summary, type, prority, status…) but not all of them. I’m afraid if I have to map all fields, the Jira expression will be too long and it will fail. Using the search API is really simple, you only have to use the fields query param.

  • Can I get the changelog of the issue using Jira expressions? With the search API you only have to ask for it in the expand query param.

Great thanks!

1 Like

Hi, @alvaro.aranda,

The reason why in the Jira expressions API you can fetch 10 times more issues is specifically that you need to explicitly say which fields you want returned. This way we can be sure your request won’t generate too much data and won’t take too long.

Hence, you can’t say “give me all fields”, but if you have a list of fields you are interested in, you could write an expression that takes that list and returns those fields for all issues. Something like:

issues.map(issue => 
   ['summary', 'updated', 'created', 'issueType', 'project', 'attachments', ... <any-other-field> ].map(field => 
     issue[field]))

You can use function literals and typeof operator to have both simple field names and functions on issue in the list. This way instead of the entire project, you could ask for just the project key, like this:

issues.map(issue => 
   ['summary', 'updated', 'created', 'issueType', i => i.project.key, 'attachments', ... <any-other-field> ].map(field => 
     typeof field == 'string' ? issue[field] : field(issue)))

If a field you are extracting properties from can be null, first check if it isn’t, for example: i => i.assignee && i.assignee.accountId.

When working with expressions that return a lot of data, keep the restrictions in mind.

Changelogs are currently not available in Jira expressions. There is an issue for this that you can vote on and watch: https://ecosystem.atlassian.net/browse/ACJIRA-1901

4 Likes

@alvaro.aranda Jira expression REST API is useful only when requesting few fields per one issue. As we learned when you try to request a lot of fields then you will get an error

Maximum number of values in the response exceeded. Limit: 10000

Which means that the expression is returning more than 10K primitive values in the response JSON object. So if you will request 1000 issues and each issue will have more than 10 primitive values (numbers, strings) in the response object then the request will fail.

For requesting all issue fields you should still use the issue search API.

Kind regards,
Raimonds

2 Likes

Thank you both @kkercz & @raimonds.simanovskis!

I will follow your guidelines, if I’m taking all fields from an issue I’ll use the search API, but for several fields Jira expressions look so good.

Cheers.

2 Likes