Search code examples
pythonjirapython-jira

How to retrieve the 'links' associated with a JIRA ticket using jira-python?


I am trying the following expression to retrieve data about a JIRA ticket with jira-python, including the links:

issue = self.jira.search_issues("key=MYPR-11", fields=["links", "worklogs", "created","timetracking", "updated", "status", "Severity", "priority", "type", "fixVersions", "affectedVersions","components", "labels", "reporter", "assignee"])

but when looking at the available fields it seems that 'links' is missing:

print(dir(issue.fields))
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'assignee', 'components', 'created', 'customfield_10010', 'fixVersions', 'issuetype', 'labels', 'priority', 'reporter', 'status', 'timetracking', 'updated']

Any idea how I can query the 'links' information with `jira-python?


Solution

  • I am not quite sure what you want for links, but I assume you need the issue links. You used the wrong fieldname. Instead of links the field is called issuelinks.

    issue = self.jira.search_issues("key=MYPR-11", fields=["issuelinks", "worklogs", "created","timetracking", "updated", "status", "Severity", "priority", "type", "fixVersions", "affectedVersions","components", "labels", "reporter", "assignee"])
    

    If you want to have all availlable fields, try *all to include all fields . https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-getIssue

    I am not sure if jira-python supports this

    EDIT

    As @Alex mentioned: if no fields are specified, all available fields are returned.