I have a custom field that has multiple options.
I am trying to update Option 1 via a script using ScriptRunner
put("/rest/api/2/issue/${issueKey}")
.header("Content-Type", "application/json")
.body([
fields:[
"customfield_10066": [
"value": "Option1"
]
]
])
.asString()
Problem: the above script returns an error:
2018-08-30 03:54:35.081 WARN - PUT request to /rest/api/2/issue/OP-35 returned an error code: status: 400 - Bad Request body: {"errorMessages":[],"errors":{"Flag":"data was not an array"}}
where "Flag" is the name of customfield_10066
Note: I have tried wrapping the value change as follows:
[{"value": "Option1"}]
but this returns an equally fatal error:
Script1.groovy: 47: expecting '}', found ':' @ line 47, column 34. [{"value": "Option1"}] ^
Hello @alexmears
Try
put("/rest/api/2/issue/${issueKey}")
.header("Content-Type", "application/json")
.body([
fields:[
"customfield_10066": "Option1"
]
])
.asString()
or
put("/rest/api/2/issue/${issueKey}")
.header("Content-Type", "application/json")
.body([
fields:[
"customfield_10066": [[value: "Option1"]]
]
])
.asString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex,
Are you trying to update the 'Flagged' field which is provided by JIra Software out of the box?
If this is the case I have an example script console script which shows how to do this which is located here.
You will be able to use this script to see how to set the flagged field and to see an example of the syntax required for specifying an array value.
If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your solution was the same as the 2nd option above. It worked! I appreciate the inline comments in the code, because it explained that I need to "initiate the array".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex,
I am glad that we were able to help resolve your issue.
Could you please accept both answers in order to mark them both as correct for users searching for the same question.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.