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"
}
....
....
]
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your confirmation about allowedValues. Config file sounds like a good option worth considering in this situation for now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.