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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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
Try with new_issue.key.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.