0

I'm using the JIRA python library (https://jira.readthedocs.io/en/master/index.html) and I'd like to create a new issue with a "related to" inward link to an existing issue.

#Existing issue...
existing_issue_key = PROJ-123
issue_dict = {
        'project': {'id': 1},
        'summary': 'Related issue for '+existing_issue_key,
        'description': 'Look into this one',
        'issuetype': {'name': 'Story'},
        'issuelinks': [{"inwardIssue": {'key':existing_issue_key}}]

    }
new_issue = jira.create_issue(fields=issue_dict)

When I try the above, I get the error:

   JiraError HTTP 400 url: https://jira.mysite.com/rest/api/2/issue
text: Field 'issuelinks' cannot be set. It is not on the appropriate screen, or unknown.
user791793
  • 413
  • 1
  • 6
  • 19

1 Answers1

2

The key 'issuelinks' is not valid creating issues directly, so you can't create links between issues on requests that creates issues. You need to call jira.create_issue_link method after issue creation in order to create a link between issues.

  • Ah, thanks. Trying that now but how do I get the key of the newly created issue? Eg. I have this: new_issue = jira.create_issue(fields=issue_dict) but I can't use: new_issue.fields['key'] to access the new key – user791793 May 02 '19 at 09:56
  • Try with [`new_issue.key`](https://jira.readthedocs.io/en/master/api.html#jira.Issue.key). – Álvaro Mondéjar May 02 '19 at 11:03
  • 1
    That's almost there. Thanks! The only thing is how to make it a type of "is related to". The example just uses "Duplicate". I've tried: "Related" and "is related to" and neither work. – user791793 May 07 '19 at 11:58