Creating an issue using custom fields NAME instead of ID?

In your docs you explained how to create an issue using custom fields.
In your examples:

"customfield_11050" : {"Value that we're putting into a Free Text Field."}

So my question is, how can I set some custom field if I don't know ID and I know it's NAME.
I would like to do something like this:

"customfield_NAME_OF_THAT_FIELD" : {"Value that we're putting into a Free Text Field."}

Can you give me some advice how to do that?
Thank you

2 answers

1 vote

One thing you can do is cache the results of /issue/createmeta (https://developer.atlassian.com/static/rest/jira/5.2.9.html#id244429) (make sure you pass in the expand=projects.issuetypes.fields query param to expand the fields. The response will give you the metadata available and required to create an issue. You'll find the fields in an array with customfields that look like this:

"customfield_10250": {
              "required": false,
              "schema": {
                "type": "string",
                "custom": "com.atlassian.jira.toolkit:message",
                "customId": 10250
              },
              "name": "Support Request Message (IssueType:Bug)",
              "operations": [
                "set"
              ]
            }

Extract all of your customfields by name then cache their keys so you don't have to look them up on every issue creation.

You can play with the API here: https://jira.atlassian.com/plugins/servlet/restbrowser#/com-atlassian-jira-rest-jira-rest-filter

Thanks this was what I was looking for

Hi Ben,

Looking at your inquiry here, I believe that you are trying to create an issue using JIRA REST API. If this is true, then I am afraid that it is only possible for us to assign a value to a custom field during issue creation using the custom field ID. I have tried this before, and if I am not mistaken it is not possible for us to supply the field name in the JSON data.

I hope that this clarifies the matter.

As a supplement to this comment, perhaps the following documentation may help:

- https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue

Hi Ahmad,

I forgot to mention that I'm using JIRA REST API. Sorry about that.
So there is no other way to do that without using customfield_id?
One more question:
Is "Environment" field default for all your accounts on Jira?
I mean does everyone have field with id:"environment", name:"environment"?

Can I please get update for my last question?
thank you

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 4 hours ago in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

16 views 0 3
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