Jira Cloud fields and work types
Jira radio buttons custom field: set and read via API
Radio buttons hold exactly one option, so the value is a single option object, not an array. Over REST the field behaves like the single choice select list, down to the option object that comes back.
Endpoints
| Method | Path | What it does |
|---|---|---|
PUT | /rest/api/3/issue/{issueIdOrKey} | Sets or changes the value. |
GET | /rest/api/3/issue/{issueIdOrKey} | Reads the stored value. |
GET | /rest/api/3/issue/{issueIdOrKey}/editmeta | Lists what can be edited. |
Examples
PUT /rest/api/3/issue/{issueIdOrKey}
Chooses Yes by option text and gets the option object back.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10166": {
"value": "Yes"
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10166'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10166',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10166'},
json={'fields': {'customfield_10166': {'value': 'Yes'}}},
)
print(r.status_code, r.text)Response: HTTP 200
{
"key": "ZZREF-6",
"fields": {
"customfield_10166": {
"self": "https://your-domain.atlassian.net/rest/api/3/customFieldOption/10042",
"value": "Yes",
"id": "10042"
}
}
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
An option that does not exist is refused.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10186": {
"value": "Maybe"
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10186'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10186',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10186'},
json={'fields': {'customfield_10186': {'value': 'Maybe'}}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"customfield_10186": "Specify a valid value for zz-ref radio"
}
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
Null clears the field.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10186": null
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10186'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10186',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10186'},
json={'fields': {'customfield_10186': None}},
)
print(r.status_code, r.text)Response: HTTP 200
{
"key": "ZZREF-11",
"fields": {
"customfield_10186": null
}
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}
Reading the work item returns the same option object under the field id.
curl
curl -G \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
--data-urlencode 'fields=customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'fields': 'customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"key": "ZZREF-6",
"fields": {
"customfield_10166": {
"self": "https://your-domain.atlassian.net/rest/api/3/customFieldOption/10042",
"value": "Yes",
"id": "10042"
}
}
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}/editmeta
Edit metadata gives the options that can be chosen and the operation set.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"fields": {
"customfield_10166": {
"name": "zz-ref radio",
"operations": [
"set"
],
"allowedValues": [
{
"value": "Yes",
"id": "10042"
},
{
"value": "No",
"id": "10043"
}
]
}
}
}Sent to Atlassian Cloud on .
How it behaves
- Type key com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons, searcher key com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher, schema type option, display name "Radio Buttons".
- {"value": "Yes"} answered 200 and the field read back as {"self": ..., "value": "Yes", "id": "10042"}.
- {"value": "Maybe"} gave 400 "Specify a valid value for zz-ref radio".
- {"fields": {id: null}} answered 200 and the field came back null.
- Edit metadata shows operations ["set"] only, with the allowed options Yes and No in allowedValues.
Pitfalls
- The message for an unknown option is keyed by the field id but names the field by its display name.
- Null empties the field; whether a required radio field blocks that depends on the field configuration, which was not probed.
- The searcher is the select list searcher, so JQL uses the same = and in forms as for a select list.
Questions and answers
Can a radio buttons field hold more than one value?
No. The edit metadata lists only the set operation and the value is one option object.
Related
- Select list (single choice)
- Checkboxes
- Select list (multiple choices)
- Options of select and cascading fields
- Default values