Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,546
Community Members
 
Community Events
165
Community Groups

Jira Next-Gen Python API Create Issue with Custom Field

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

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

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you