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

How do I set a custom field value to "None" using the REST API?

Gervase Markham July 7, 2016

This question is in reference to Atlassian Developer Documentation: Updating an Issue via the JIRA REST APIs

Using the REST API, I can't seem to set the value of a custom field to the value which is displayed as "None" in the web UI.

I've seen https://answers.atlassian.com/questions/131241 , but that does not specifically relate to the REST API. It says to send a null value, but doing:

{
   "update" : {
      "customfield_11139" : [
         {
            "set" : {
               "value" : null
            }
         }
      ]
   }
}

gives the error:

400 Bad Request

{"errorMessages":[],"errors":{"customfield_11139":"Could not find valid 'id' or 'value' in the Parent Option object."}}

Trying:

{
   "update" : {
      "customfield_11139" : [
         {
            "set" : {
               "value" : "None"
            }
         }
      ]
   }
}

gives:

400 Bad Request

{"errorMessages":[],"errors":{"customfield_11139":"Option id 'null' is not valid"}}

Exactly the same error is thrown if I send the empty string as the value.

Setting the value to one of the other legal defined values works fine. BTW, this is using JIRA 7.0.10.

 

Does anyone know how I do this?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Yit Wei
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 11, 2016

I've just created this article on how to set a Select List to None

 

{
  "fields": {
    "customfield_11139": null
  }
}

 

 

Gervase Markham July 12, 2016

Thank you for this. However, it is inconvenient for my code to restructure the message entirely if the value is "null". At the moment, as you see, I am using:

"update" : { "customfield_11139" : [ { "set" : { "value" : <value> } } ]  }

Is there a way to do this within that structure?

If not, can I change it to always use:

"fields": { "customfield_11139": null } }

? Will that work to set any value, not just null? What is the difference between these different methods of setting the field values?

Gerv

Yit Wei
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 12, 2016

I just tested with the following and it works as well

{
  "update" : { "customfield_10200" : [ { "set" : null } ]  }
}

 

The original one using "fields" works with any values but I only tested for Select List. You can check out the article where I actually used it to set a value. I'm not sure if it works with other types of custom field.

 

However I'm not sure about the differences between them though.

 

Yit Wei

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 7, 2016

I seem to remember

"value" : ""

being worth a try

Gervase Markham July 8, 2016

"Exactly the same error is thrown if I send the empty string as the value."

--> I tried that :-|

Gerv

TAGS
AUG Leaders

Atlassian Community Events