Custom Field ids with restfull API

I'm writting an application which needs to be able to create tickets using the RESTful API. I'm using the java rest client (version 1.0) to do this. When creating issues, I need to populate two custom fields. At the moment I'm using the custom field id customfield_10021 for example. Am I am able to set the field value by the actual name of the field, or look up the field id by its name in some way. I'm not eager to leave the custom field ids hard coded as I imagine they'll be different on different JIRA instances (we actually have 3 running, a local develoment copy, a test instance and a production instance).

1 answer

1 accepted

Hi, here's a sample code for getting field id by name for a project that should help you write your own function:

private String getFieldId(String projectKey, String fieldName) {
		GetCreateIssueMetadataOptions options = new GetCreateIssueMetadataOptionsBuilder()
		Iterable<CimProject> metsdata = restClient.getIssueClient().getCreateIssueMetadata(options)
		CimProject cim = metsdata.iterator().next();
		for (CimFieldInfo info : cim.getIssueTypes().iterator().next().getFields().values()) {
			if(info.getName().equals(fieldName)) {
				return info.getId();
		return null;

Just what I was looking for. Thanks Boris!

Would you mark my answer as accepted ?


Works, Thanks.

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
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

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