Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

API Update customfield checkbox

Fernando Simões
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 19, 2022

Hi.

i'm trying to update a few checkboxes without sucess.

Untitled.png

Untitled.png

I'm stuck here:

{
  "fields":{
   "customfield_13304": [{"value""Yes" }, {"value""Yes" }]
               }
}

The response is 204, but only the first option is being ticked.

Can someone help please?

2 answers

0 votes
Florian Bonniec
Community Champion
December 19, 2022

Hi @Fernando Simões 

You send an array with 2 times the same value.

 

Regards

0 votes
Sunny Ape
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2022

Hello @Fernando Simões 

I've just re-read your question and got a bit confused.

Since you haven't advised which REST API endpoint you're using or the actual request you are sending, only some JSON, it's not clear if you are trying to change the value of the checkbox options ('Yes" and "No") or the state of the options (ticked or not ticked)?

Untitled.png

A checkbox field with two options with the same value of 'Yes', both of which could be enabled (ticked), wouldn't make any sense :-)

If you want to set the state of both the options to be ticked, you have to reference both their values, like this:

{
"fields":{
"customfield_13304": [
{
"value": "Yes"
},
{
"value": "No"
}
]
}
}

This is effectively saying "If there are two possible matching options, Yes and No, set them both"

The logic of unticking an option is completely bizzare!! There is no way to direct a single option to be unticked, as far as I can work out, except to set all the other possible option choices to one value. IE, to untick the No option in your example, would require:

{
"fields":{
"customfield_13304": [
{
"value": "Yes"
},
{
"value": "Yes"
}
]
}
}

 ... hence the problem you encountered, as you were effectively saying "If there is a Yes option, set it for both possible choices".

Suggest an answer

Log in or Sign up to answer