Trouble with Jira Python creating an issue

Hello - i'm attempting to create a script to incorporate in our Cloud based app to create an issue within Jira using the Python Module . 

When i run the following code I recieve the below error.

new_issue = jira.create_issue(project='OPS', summary="Savage-Test", description="savage-test", issuetype={"name": "Request"}, components=[{"Name": "SysAdmin-VMware"}],fields={'customfield_11107': [{'value': 'Not Applicable'}]})

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/lib/python2.7/site-packages/jira/jirashell.pyc in <module>()
----> 1 new_issue = jira.create_issue(project='OPS', summary="Savage-Test", description="savage-test", issuetype={"name": "Request"}, components=[{"Name": "SysAdmin-VMware"}],fields={'customfield_11107': [{'value': 'Not Applicable'}]})

/usr/lib/python2.7/site-packages/jira/client.pyc in create_issue(self, fields, prefetch, **fieldargs)
    885         data = _field_worker(fields, **fieldargs)
    886
--> 887         p = data['fields']['project']
    888
    889         if isinstance(p, string_types) or isinstance(p, integer_types):

KeyError: u'project'

The customfield_11107 is a required field to create issues within the SysAdmin-VMware component.

Thoughts?

1 answer

0 vote
Shaun Seaver Atlassian Team Oct 17, 2017

Hi Adam,


When I try to create an issue by passing the values for an issue (project, summary, description, issue type, etc) I receive the same KeyError. I noticed you raised this issue on the Github page for the repository, and I attempted to use the method in the answer without success. I was able to change the method for defining the data on the custom field to successfully create the issue. Passing the create_issue method a dictionary of values like the following should work. I hope that helps!

 

issue_dict = {
'project': {'key': 'OPS'},
'summary': 'Savage-Test',
'description': 'savage-test',
'issuetype': {'name': 'Request'},
'customfield_11107': 'Not Applicable'
}
new_issue = jira.create_issue(fields=issue_dict) 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

121 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you