Creating EPIC links

Miguel Corazao
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!
May 4, 2020

Newbie question: I've been successfully using the Jira REST API to create some issues. I am now trying to create Epic links and I am confused as to how this is supposed to work. I found a custom attribute that that appears to be relevant. I tried setting this attribute to the issue ID of the Epic using a structure like

    {

        "fields": { "customfield_13401": "MYPROJ-100" }

    }

and I got

    gh.epic.error.not.found

My questions are, then:

  • Is setting this custom field the correct way to set the Epic link?
  • If so, what value am I supposed to use?
  • Is there a canonical way to determine what the custom field name is through the API? Presumably the field name could change in the future so ideally I should have the script determine this dynamically, right?

Any help is appreciated.

1 answer

0 votes
David_Bakkers
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 18, 2020

That looks like the correct format.

Are you 100% sure your Epic Link field has that customfield ID number and you have an Epic with that Key?

Miguel Corazao
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!
May 18, 2020

I actually managed to get it working. I had the Epic ID name wrong.

My only question at this point is whether there is a reliable way to retrieve the field ID through the script rather than hard-coding it. My concern is that if our administrators were to change the ID at some point in the future the flow would break and it might not be obvious to anybody why.

David_Bakkers
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 18, 2020

Glad to hear it was just a typo.

An admin changing a custom field is a possibility, but it's rare. It's more common that two custom fields with the same name but with different IDs have been created.

You can deal with the first possibility by:

1. Getting all the fields by calling the rest/api/2/field endpoint. then iterating through the results to find the one you want. This can't overcome two fields with the same name. If you encounter this, just bring it to the attention of the admins to change one of the field's name.

2. Store the names and IDs of the custom fields in a local configuration file that the script parses at run time. You could store that config file in a distributed location to centralise that data.

In Jira Cloud, v3 of the REST API has a new endpoint that returns the list of fields in a paginated format, so that you can filter the request to only return fields that match a pattern, start at a certain number, have the results returned in a particular order etc. This makes looking up fields much easier and hopefully this will come to Jira Server soon.

Suggest an answer

Log in or Sign up to answer