Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get issue key after I create jira issue using create_issue() in jira module in python?

anmol sharma
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 7, 2019

When I create a jira ticket using create_issue function in jira module in python, I'm not able to extract that  issue's key even after the ticket was successfully created. How do I get the issue key?

3 answers

2 accepted

1 vote
Answer accepted
Tarun Sapra
Community Champion
May 7, 2019

Hello @anmol sharma 

As per the docs

https://jira.readthedocs.io/en/master/examples.html#issues

"Successfully created issues will contain the issue object as a value of the issue key."

Tarun Sapra
Community Champion
May 7, 2019
issues = jira.create_issues(field_list=issue_list)
0 votes
Answer accepted
Joe Webb
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 19, 2023

It gives you that issue because the create_issue command returns the issue key not a JSON object so in the following example you can use the output as the new key

I.E

 

new_issue_key = auth_jira.create_issue(fields=issue_dict)
print(new_issue_key)
$ JRA-98
1 vote
Elifcan Cakmak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2019

Hello,

After creating the ticket, result should return a JSON such as:

{
"id": "12345",
"key": "KT-5",
"self": "https://jiraurl/rest/api/2/issue/12345"
}

Here you can extract the key by using :

result_json["key"]

 Regards.

Edgar Oregel
Contributor
March 31, 2020

This did not work for me. I tried to index and got the error:

Arguments: (TypeError("'Issue' object is not subscriptable",),)

When i try to loop through the items of the object to see if it indeed returned a Json item, i get error:

Arguments: (TypeError("'Issue' object is not iterable",),)

If i print out typeof(new_issue), i get:

<class 'jira.resources.Issue'>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events