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.
asked May 1, 2019 at 14:22
user791793
7212 gold badges7 silver badges25 bronze badges
1 Answer 1
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.
answered May 1, 2019 at 14:33
Álvaro Mondéjar
5044 silver badges19 bronze badges
Sign up to request clarification or add additional context in comments.
3 Comments
user791793
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
Álvaro Mondéjar
Try with
new_issue.key.user791793
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.
lang-py