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.
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.
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.
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.