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 votes
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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,774 views 11 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot