Creating an issue using custom fields NAME instead of ID?

Ben Arent March 19, 2013

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

2 votes
rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 24, 2013

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

oswaldo zapata January 21, 2018

Thanks this was what I was looking for

0 votes
Faisal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2013

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.

Faisal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2013

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

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

Ben Arent March 19, 2013

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"?

Ben Arent March 20, 2013

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

Suggest an answer

Log in or Sign up to answer