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?
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."
issues = jira.create_issues(field_list=issue_list)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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'>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.