Navy Seal
Navy Seal

Reputation: 125

Retrieve Jira ID after Creating A Jira

I wanted to check if there was a way to return a issue ID after sending a request for one.

Below is my code

issue_dict = {
    'project': {'id': 123},
    'summary': 'New issue from jira-python',
    'description': 'Look into this one',
    'issuetype': {'name': 'Bug'},
}
new_issue = jira.create_issue(fields=issue_dict)

Is there a way, I can retrieve the issue ID here or do I need to setup another query?

Thanks

Upvotes: 0

Views: 2046

Answers (1)

FLeX
FLeX

Reputation: 524

According to the documentation create_issue will return an Issue which has the ID and the issue key.

issue_dict = {
    'project': {'id': 123},
    'summary': 'New issue from jira-python',
    'description': 'Look into this one',
    'issuetype': {'name': 'Bug'},
}
new_issue = jira.create_issue(fields=issue_dict)
print(new_issue.id)
print(new_issue.key)

Upvotes: 3

Related Questions