Creating an issue in Jira from python error - Epic Link Field is Empty

96 Views Asked by At

I am trying the very basics of creating a task in jira through python using the module jira==3.5.2: https://jira.readthedocs.io/

I have the following code in my constants.py file:

from jira import JIRA

JIRA_TOKEN = "TOKEN"

ji = JIRA('https://ourdomain.atlassian.net', basic_auth=('[email protected]', JIRA_TOKEN))

And the following code in main.py:

from constants import *
from pprint import pprint

def jira_create_issue(summary: str, description: str):

    issue_dict = {
        'project': {'key': 'QD'},
        'summary': 'TEST JIRA PYTHON',
        'description': 'test',
        'issuetype': {'name': 'Bug'},
    }

    new_issue = ji.create_issue(fields=issue_dict)

def main():
    jira_create_issue("test rest", "test rest1")

if __name__ == "__main__":
    main()

Whenever creating an issue like this, I get an HTTP 400 error saying:

response text = {"errorMessages":["Epic Link Field is Empty !"],"errors":{}}

When I try to include the epic link field in issue_dict (I've tried many forms: epiclink, EpicLink, Epic Link, epic link, epic and so on...), I get the following error:

response text = {"errorMessages":[],"errors":{"Epic Link":"Field 'Epic Link' cannot be set. It is not on the appropriate screen, or unknown."}}

What am I doing wrong? When opening a task in out Jira dashboard manually, I do have an Epic Link field with a drop down to set. But what is the name of the key of it? It isn't written anywhere in the docs.

1

There are 1 best solutions below

0
On

It turns out that Epic Link is a custom field added by my company, therefore it's "display name" is different from it's actual key.

I found out that it's key was customfield_10002 by using the method JIRA.fields() which returns a list of all issue fields. I then just searched using ctrl + F for Epic Link, and looked at it's key.

My final issue_dict looks like so:

issue_dict = {
        'project': {'key': 'QD'},
        'summary': 'TEST JIRA PYTHON',
        'description': 'test',
        'issuetype': {'name': 'Bug'},
        EPIC_LINK_FIELD: "QD-9913"
    }

where EPIC_LINK_FIELD is said key and QD-9913 is the key of the epic link I need (can be found under the name of each epic link in the epic link dropdown).