Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Issue color custom field, no allowed values returned from jira rest api Edited

Hi,

 

When trying to get information about the custom field for "Issue color" there is no property "allowedValues" which contains valid colors that we can use.

 

For example result of this API call: /rest/api/3/issue/createmeta?projectKeys={projectKey}&expand=projects.issuetypes.fields

...
...
"customfield_10017": {
"required": false,
"schema": {
"type": "string",
"custom": "com.pyxis.greenhopper.jira:jsw-issue-color",
"customId": 10017
},
"name": "Issue color",
"key": "customfield_10017",
"hasDefaultValue": false,
"operations": [
"set"
]
}
...
...

 

And when we try to create new Issue with this part in JSON request:

...
...
{
"name": "customfield_10017",
"type": "STRING",
"value": "red"

...
...

 

We get:

{
"statusCode": "ERROR",
"message": "Error during HTTP request execution: com.google.api.client.http.HttpResponseException: 400\n{\"errorMessages\":[],\"errors\":{\"customfield_10017\":\"Invalid color value 'red'. Allowed values are: [purple, blue, green, teal, yellow, orange]\"}}"
}

 

What we need is a way to ask JIRA API to return valid colors to us, so we can present them on our frontend dynamically. Is this possible?

For example, some fields have this info (this example is from Priority field):

"allowedValues": [
{
"self": "https://xyz.atlassian.net/rest/api/3/priority/1",
"iconUrl": "https://xyz.atlassian.net/images/icons/priorities/highest.svg",
"name": "Highest",
"id": "1"
},
{
"self": "https://xyz.atlassian.net/rest/api/3/priority/2",
"iconUrl": "https://xyz.atlassian.net/images/icons/priorities/high.svg",
"name": "High",
"id": "2"
}
....
....
]

 

1 answer

I've not heard of the property 'allowedValues' that can be queried for a field. Which version of the REST API are you using?

In v3, the GET create issue meta method has been deprecated and replaced with GET create issue meta fields, as in:

GET /rest/api/3/issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId}

 

Personally, since this is a custom field that you created, you already know what values it allows, so why bother using the REST API to find out you what you already know?

We are connecting to different client's Jira systems and we don't know what they configured in their accounts. What we do is getting all the info from Jira API first, displaying available fields in our frontend which will be different for different clients.

This current problem that we have is mostly with fields that were added by the Greenhopper Jira plugin. Those fields have restrictions on them that are not configurable, but those restrictions are not reported through API so we have to guess them and hardcode them and we would like to avoid that.

As I wrote above, this custom field 

"custom": "com.pyxis.greenhopper.jira:jsw-issue-color"

It has only a few colors allowed, they are not configurable, but they are not reported anywhere. If those colors change from version to version, then we will have problems when different clients with different versions of Jira software connect through our application.

OK, I understand now. There are other threads about not being able to get allowedValues for certain custom fields. The REST API has limits, and this looks like one of them. You might be just out of luck and have to hard code values for those fields.

You could get around this limit by storing those custom field names, IDs and values in a config file, which is parsed by your application on startup. This would allow you to quickly adapt to any changes to those custom fields without the coding overhead or uncertainty of having to query their values using the REST API.

Like Team Nautilus likes this

Thanks for your confirmation about allowedValues. Config file sounds like a good option worth considering in this situation for now.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

4,308 views 22 31
Read article

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