I have a multi checkbox and if I try to submit the data as an array
I get this error
{
“status”: “error”,
“message”: “Invalid input JSON on line 33, column 13: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)”,
“correlationId”: “8ab28e02-2ae2-4cac-a2a2-d602a0d9ce27”
}
This is my request data
{
fields: [{
“name”: “toa”,
“value”: true
},
{
“name”: “radio”,
“value”: “Option 2”
},
{
“name”: “multicheck”,
“value”: [
“val3”,
“val2”,
“val1”
]
}]
}
It seems like the API is expecting the values of the fields to be strings instead of arrays. You may need to convert the array values to strings before submitting the data.
Here’s an example of how you can modify your request data
the array of checkbox values is converted to a string by joining the values with commas. This way, the API can deserialize the request data correctly.
Alternatively, you may want to check the API documentation to see if there is a specific way to submit array values for checkboxes or multiple select fields.
Thank you for the reply, I tried that way but then when I view form submission it says that value is not one of the allowed options
but if I submit a new object for every value in the array like
[
{
name:“multicheck”,
value:“val2”
},
{
name:“multicheck”,
value:“val3”
}
]
Then it is working
Based on the error message you received, it seems that the API is expecting a string for the `multicheck` field, but you are sending an array of strings.
To fix this, you can convert the array of strings to a single string with the values separated by a delimiter. For example, you can join the array with a comma delimiter:
Then you can send this updated request data to the API. Note that you will also need to update your server-side code to handle the comma-separated string correctly.
Hope this will helps you out. If you find it helpful, Please mark it as solution.