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 votes

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,755 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot