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

This widget could not be displayed.
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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

155 views 2 0
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