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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Value isn't sent in REST call using ScriptRunner Edited

If I run the following code in ScriptRunner's script console, I get an error back from the response that says I didn't set the value for the 'value' field.

def result = put("/rest/api/3/customField/12345/option")
.header('Accept', 'application/json')
.header('Content-Type', 'application/json')
.body([
options:[
[
value: 'A_VALUE'
]
]
])
.asString()

if (result.status == 201) {
return "Success"
} else {
return "${result.status}: ${result.body}"
}

The error that I get is:

400: {"errorMessages":["Every option is required to have a non empty field 'value'."],"errors":{}}

It seems to me like the value field is NOT empty.

Note that I can run the request in Postman without any errors.

1 answer

Hi Mikey,

Not Sure if you got this resolved or not, but I'm posting for those like me who Google upon this post. 

The issue as I can tell is that the "options" parent is looking for both "newValue" and "value" even if not updating the parent value.

 

{
"options": [
{
"newValue": "ParentName",
"value": "ParentName",
"cascadingOptions": [
{
"newValue": "NewChildValue",
"value": "OldChildValue"
}
]
}
]
}

 Which is not how I would interpret the documentation.JiraCapture.PNG

Hi, Casey. Thanks for posting. I never resolved this using ScriptRunner, so I just moved forward using Postman and an API token. The body of the request looked like this:

{
"options": [
{"value" : "Alpha"},
{"value" : "Bravo"},
{"value" : "Charlie"}
]
}

 Note that it looks like our use cases might have been different as it looks like you were changing values and I was creating new options values.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Marketplace Apps & Integrations

🤺 Atlympic Event: Partnerships

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

62 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you