How to get the {id} of a project version through the REST api?

valipost nicolas August 21, 2013

Hello!

I'm trying to get used to the rest API, as I want to update the description of a version with it.

I already found how to do it, but you need the version id to do it, and I don't know how to get it with the API. When I write something like this :

curl -i -u username:password -H "Content-Type: application/json" -X GET -d http://jira/rest/api/latest/project/SBX/versions

I get every version of it. How can I do to only get the ID of the version named "V5" ?

Thank you

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
RambanamP
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.
August 21, 2013

as of now there is no REST to get project version by name, check this doc for latest REST api's

https://docs.atlassian.com/jira/REST/latest/

only way is you have to get all project versions and iterate response and need to get ID

tony cameraman August 31, 2018

@valipost nicola  HI can You post the answer? I know it is too long time ago, But if possible please post it. 

TomiTomo January 11, 2019

@tony cameraman you can use this:
project_versions(project)[source]

Get a list of version Resources present on a project.

Parameters:Return type:

project (str) – ID or key of the project to get versions from
List[Version]

 

in Python 3:

#prints out 10 latest version name & id
for version in jira.project_versions(project_key)[-10]:
print(version.name,' | id:',version.id)
0 votes
Lee Correll
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.
July 31, 2014

I don't use the version field - but if it's like the fixVersion field, the answer is yes.

Run a query to find any single JIRA issue in version V5.


https://jira/rest/api/latest/search?jql=fixVersion=7.3.2.3&maxResults=1&fields=*all

then look at result.issues.fields.fixVersions.id.

Does that help?

Manuel Nazar Anchorena September 25, 2018

Cool workaround... its weird to this date there is no "get version by name"

TAGS
AUG Leaders

Atlassian Community Events