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

1 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
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

1,385 views 17 10
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