Update Select List value to "None" in JIRA using REST API

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

This is an example of how to update an issue using REST API to set a Select List custom field value to "None"

Solution

  1. First verify the ID of the custom field
    - Either query through the database

    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


  2. 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 value

    { 
      "fields": {
        "summary": "This is the summary of the issue",
        "description": "And this is the description",
        "customfield_10200": {  "value": "a"}
      }
    }
  3. Once verified that it works, use the following to set the select list value to "None"

    {
      "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:

  1. Retrieving the information through REST:

    % 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",
        ...
    }
  2. Set the new value through REST:

    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"
  3. Retrieving the information through REST (now modified):

    % 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",
        ...
    }




Last modified on Dec 12, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.