Update Select List value to "None" in JIRA using REST API
Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This is an example of how to update an issue using REST API to set a Select List custom field value to "None"
Solution
First verify the ID of the custom field
- Either query through the database
1
select id from customfield where cfname='<name of customfield>'
- Or you can navigate to the Custom Fields page, click the cog icon for your custom field and hover over the Delete button. The bottom left of the screen will display the id
Referring to JIRA REST API Reference, use PUT for
/rest/api/2/issue/{issueIdOrKey}
and first test this by updating the custom field to an existing value1 2 3 4 5 6 7
{ "fields": { "summary": "This is the summary of the issue", "description": "And this is the description", "customfield_10200": { "value": "a"} } }
Once verified that it works, use the following to set the select list value to "None"
1 2 3 4 5 6 7
{ "fields": { "summary": "This is the summary of the issue", "description": "And this is the description", "customfield_10200": null } }
Example
Below you may find the data retrieve and modification through REST api, curl and Personal Access Token:
Retrieving the information through REST:
1 2 3 4 5 6 7 8 9 10 11 12 13
% curl -k -L --header 'Authorization: Bearer MjgyNjgwNjQ0ODg3Or2VE4ycE7w/Y2cMc6JzAztY8joe' -X GET "http://localhost:8080/rest/api/latest/issue/SD-15" | python3 -mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 8754 0 8754 0 0 161k 0 --:--:-- --:--:-- --:--:-- 185k { "expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations", "id": "13307", "self": "http://localhost:8080/rest/api/latest/issue/13307", "key": "SD-15", ... "customfield_11200": "custom_value", ... }
Set the new value through REST:
1
curl -k -L --header 'Authorization: Bearer MjgyNjgwNjQ0ODg3Or2VE4ycE7w/Y2cMc6JzAztY8joe' -X PUT --data '{ "fields" : { "customfield_11200" : "NEW CUSTOM DATA" } }' -H "Content-Type: application/json" "http://localhost:8080/rest/api/latest/issue/SD-15"
Retrieving the information through REST (now modified):
1 2 3 4 5 6 7 8 9 10 11 12 13
% curl -k -L --header 'Authorization: Bearer MjgyNjgwNjQ0ODg3Or2VE4ycE7w/Y2cMc6JzAztY8joe' -X GET "http://localhost:8080/rest/api/latest/issue/SD-15" | python3 -mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 8759 0 8759 0 0 79162 0 --:--:-- --:--:-- --:--:-- 85038 { "expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations", "id": "13307", "self": "http://localhost:8080/rest/api/latest/issue/13307", "key": "SD-15", ... "customfield_11200": "NEW CUSTOM DATA", ... }
Was this helpful?