Body for Checkbox set value in Jira Rest API with POST in Scriptrunner is not valid object

Fawaz Joseph October 27, 2023

So I'm trying to set checkbox values using script runner specifically Script Listener.

This is the code I'm trying to execute

 put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
"customfield_10036": [
[["value": "ALL"], ["value": "BT7"], ["value": "MACS"], ["value": "SPINS"], ["value": "BT4"], ["value": "NGB30"], ["value": "NG7S"]]
]
]
]).asString()

However for some reason, I get this error

body: {"errorMessages":[],"errors":{"Instrument":"The Instrument value must be an object"}}

 

How the value not an object.

Thank you

1 answer

1 accepted

4 votes
Answer accepted
Kristian Walker _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.
October 27, 2023

Hi Fawaz,

I can confirm we have an example script that can be run  on the script console that shows how to set a checkbox field here.

You will be able to use this script to help write the rest API call neeed to set the checkbox values via a script listener.

I hope this helps.

Regards,

Kristian

Bobby Bailey
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.
October 27, 2023

Just to add, the only issue with your call @Fawaz Joseph is you have 1 too many sets of brackets, 

 

[["value": "ALL"] <- all your other options -> ["value": "NG7S"]]


Should become:

["value": "ALL"] <- all your other options -> ["value": "NG7S"]
Fawaz Joseph October 27, 2023

Thank you @Bobby Bailey 

This fixed my problem

Thank you for the snippet @Kristian Walker _Adaptavist_ 

This will be very useful going foward

Kristian Walker _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.
October 30, 2023

Hi Fawaz,

You are welcome, and I am glad we managed to help you to achieve your requirement.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events