Jira Next-Gen Python API Create Issue with Custom Field

Dat Mai May 23, 2022

I'm using the python REST API for Jira to create new issues in Jira (next gen). I am able to do so using bare bones commands:

issue_dict = {
'project': 'AT',
'summary': 'Testing custom field',
'description': 'Look into this one',
'issuetype': 'Test Issue'
}
issue = jira.create_issue(fields=issue_dict)

However, when I try to create a new issue while providing a value for a custom field, I get an error. I have already created this custom field in my Jira instance by dragging the "short text" option to the "context fields" section under Project Settings > issue types. Code and error below:

issue_dict = {
'project': 'AT',
'summary': 'Testing custom field',
'description': 'Look into this one',
'issuetype': 'Test Issue',
'Species': 'Homo sapiens'
}
issue = jira.create_issue(fields=issue_dict) 

Screenshot 2022-05-23 174446.png

My understanding is that custom fields work differently between classic and next-gen Jira and most of the queries I see online with regards to this refer to classic Jira. Does anyone have any advice regarding this issue? Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Dat Mai May 24, 2022

I found a solution that worked for me. Instead of providing the name of the custom field, I looked for the custom field id based on this: https://community.atlassian.com/t5/Jira-Software-questions/Project-ID-and-Custom-Field-ID-on-next-gen-project/qaq-p/1095295. Specifically, I went to the link below and looked for the some id associated with the custom field of interest.

https://your-domain.atlassian.net/rest/api/3/field

So my code looked something like this:

issue_dict = {
'project': 'AT',
'summary': 'Testing custom field',
'description': 'Look into this one',
'issuetype': 'Test Issue',
'customfield_10027': 'Homo sapiens'
}
issue = jira.create_issue(fields=issue_dict) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events