Get version by name via rest API

I only have the name of a version that needs to be set to released. In order to close it I need the corresponding id. The following api returns a list of all versions for a specifc project

http://<JIRA_HOST>/rest/api/2/project/<PROJECT_KEY>/version

I could then search the result for a matching entry and fetch the id from the response. This could be a solution. However for large projects this will not be very efficient. I am looking to filter the results by name, but I cannot find anything documented that would support something like this:

http://<JIRA_HOST>/rest/api/2/project/<PROJECT_KEY>/version?name=<VERSION_NAME>

If the API is lacking such a feature I am interested in other ways to limit te result. Maybe filtering it by status (only show unreleased versions). Or maybe a complete different approach.

1 answer

1 accepted

0 votes

As of now, there is no option to restrict the results based on version attributes. You will have to write a plugin to expose a new end point if you really need it.

The best you can do is to use pagination.

I do not wan't to write a plugin for numerous reasons, but thanks for mentioning it.

Is the order of versions in the result guaranteed or can it be changed? Per default it appears to be oldest first. The unreleased versions would most likely be the newer ones, hence will appear at the end. If I cannot determine the order, pagination will not really be helpful I reckon.

There is an orderBy option and you can order by the following fields:

  • sequence
  • name
  • startDate
  • releaseDate

Perfect. For reference sake I add that by adding a minus sign would change the default order from ascending to descending.

For example:

orderBy=-startDate will order by startDate most recent first.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,847 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot