Jira API getting version details when you have the version name

Rees, Ian May 6, 2024

I have an automation that has a Manual trigger - it is not triggered by a Version event.

In my automation, a user enters a version name as input when this rule is run manually and in the automation I want to check that the version exists

So I have the version name from the user input but how do I either get other details about the version such as the id OR just check whether the version exists

I am trying 

https://xxxxxxxx.net/rest/api/3/project/ITP/version?query=<user entered string>

and if the <user entered string> is a VALID version name, I get something like this in the response

body={self=https://xxxxxxxx.atlassian.net/rest/api/3/project/ITP/version?maxResults=50&startAt=0, maxResults=50, startAt=0, total=1, isLast=true, values=[{self=https://xxxxxxxx.atlassian.net/rest/api/3/version/35289, id=35289, name=abc, archived=false, released=false, projectId=12345}]}

But if the user enters an invalid string, the automation takes a long time to run then times out.

Is there a better way of doing this?

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
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 6, 2024

Hi @Rees, Ian 

You appear to be using this function, correct: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-versions/#api-rest-api-3-project-projectidorkey-version-get

When I call that without a matching text to a version, it comes back immediately.

 

For which versions is the person searching?

Let's assume the version needed is unreleased, and they are trying to match on the name.  The REST API query could instead pull back all of the unreleased ones with status=unreleased and then use a match() with a dynamic regular expression (built from the manual trigger input) to find the correct one, if it exists.

Kind regards,
Bill

Rees, Ian May 7, 2024

Thanks Bill,

I am basically trying to check for a mistype, where what the person has entered is not a version at all.  It doesn't matter whether the Version is Released or Unreleased.  Tbh it is quite a complex combination of automation and Automated Release Notes, that I have created to enable my internal users to test automation using a Clone on an existing version (including clones of its contents).

I've been doing some testing and I think with the above and I think I may be able to check {{webresponse.body.values.id}} is empty,null or 0 or something when an invalid version name is entered. Interesting that you get a return immediately - I will retest and see if maybe the delay I was seeing was a temporary system problem.  That insight is useful - thanks for your help

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events