Creating an Issue and its custom fields using the JIRA Python Module

I am using the JIRA Python module to automate the process of deleting and creating issues in JIRA. I am trying to create issues in JIRA using a 'for' loop in my python script that uses imported data that I have collected from another database. I need to format the fields when creating the issue so the data I have can align properly with the appropriate fields in JIRA. My Python code is below for creating the issues and storing the data to put into JIRA which is being stored in custom variables:

# Now we create a loop to input the issues from the export.csv CSV file into the fields
# of new issues that are being created in JIRA to replace the old ones that were deleted

exportList = []
with open('C:\\Python27\\scripts\\export.csv', 'r') as f:
re = csv.reader(f)
for row in re:
exportList.append(row)

# Set the column names from the export.csv file equal to variables using the pandas Python module
df = pd.read_csv('C:\\Python27\\scripts\\export.csv')
cqid = df['ClearQuest ID']
summary = df.Summary
datecreated = df['Date Created']
dateresolved = df['Date Resolved']
wistate = df['WI State']
res = df.Resolution
affected = df['Affected version/s']
fixed = df['Fix version/s']
issuetype = df['Issue Type']
priority = df.Priority
description = df.Comments

# Now do the actual loop to create new issues

for row in df:
jira.create_issue(project={'key': 'DEL'}, wistate={'customfield_1001': 'WI State'}, res={'customfield_1001': 'Resolution'}, cqid={'customfield_1001': 'ClearQuest ID'}, datecreated={'customfield_1001': 'Date Created'}, dateresolved={'customfield_1001': 'Date Resolved'}, priority={'customfield_1001': 'Priority'}, fixed={'customfield_1001': 'Fixed Version'}, affected={'customfield_1001': 'Affected Version'}, summary={'customfield_1001': 'Summary'}, description={'customfield_1001': 'Description'}, issuetype={'issuetype': 'Issue Type'})

I get the error:

JIRAError: HTTP 400: "{u'issuetype': u'issue type is required'}"

But even when I change issuetype to a custom field it still gives an error. Please let me know what I am doing wrong when creating the issue and the custom and required fields for the issue! Thanks.

1 answer

If I'm not mistaken, you should be using issuetype={'name': 'Issue Type'})

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Agile

Are you a Jira Service Desk agent? We want to talk to you!

Are you a whiz at handling tickets and looking at how you can further optimize your workflow with automation? Do you tackle detailed customer support questions while simultaneously getting flooded wi...

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