Hello,
I wish to update a checkbox field with the Jira REST API but I do not manage to set the proper "data" array.
Basically the checkbox has two values, value1 and value2. I want to update those without overwriting what was previously entered, so if the field already has value1 and I want to had value2, then it will add it without removing value1. If I want to enter value1, then it will do nothing.
Calling the api on the field tells me this:
curl -X GET --url "https://<site>.atlassian.net/rest/api/3/issue/IPP-150"
--user '<email>:<token>' --header 'Accept: appli
cation/json' | jq '.fields.customfield_14841'
[
{
"self": "https://<site>.atlassian.net/rest/api/3/customFieldOption/13860",
"value": "value1",
"id": "13860"
},
{
"self": "https://<site>.atlassian.net/rest/api/3/customFieldOption/13861",
"value": "value2",
"id": "13861"
}
]
curl --request PUT --url 'https://<site>.atlassian.net/rest/api/3/issue/IPP-150?notifyUsers=false' --user '<email>:<token>' --header 'Accept: application/json' --header 'Content-Type: application/json' \
--data '{
"update": {
"customfield_14841": [
"add": [
{
"id": "13861"
}
]
]
}
}'
Unfortunately this results in the following error
If I add brackets surrounding the "add" key (as seen in some docs), I get the following one:
Bonjour Antoine,
If you are using Checklist for Jira, I suggest you to use the edit operation since you wish to modify the value of an existing checklist item.
I am not sure if your issue is about how the JSON in interpreted, but I usually use a file pointer instead of JSON directly in the curl execution. Example:
curl -u user:password -X PUT --data "@update.json" -H "Content-Type: application/json" http://localhost/rest/api/2/issue/PROJ-10
There's a file in the same folder named `update.json` that contains the JSON payload.
I hope this helps!
Regards
Hello @Antoine _Klee Group_
You said you are trying to update a checkbox field, but you have provided a link to the REST API documentation for the third party add-on Checklist for Jira, which is a totally different thing.
Also, in your question, you said you wanted to update (alter) the existing options, but then you said you wanted to add (create) a new option, so it's not clear which of the two you meant
Assuming you really meant Jira's built-in checkbox fields and you just want to update (change) one or both of the options and not add (create) a new option, in your cURL example you are sending the PUT request to the wrong endpoint using the wrong method.
The correct v3 endpoint for Jira Cloud is Update custom field options endpoint:
PUT /rest/api/3/field/{fieldId}/context/{contextId}/option
and the JSON in the request body to update one or more existing options for a checkbox field would look something like this:
{
"options": [
{
"id": "12345",
"value": "First checkbox option"
},
{
"id": "12346",
"value": "Second checkbox option"
}
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.