# Submitting data as an array

**URL:** <https://community.hubspot.com/t/submitting-data-as-an-array/80522>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [May 3, 2023, 7:26pm UTC](https://community.hubspot.com/t/submitting-data-as-an-array/80522 "2023-05-03T19:26:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![endrits079](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@endrits079](https://community.hubspot.com/u/endrits079)\
**Post date:** [May 3, 2023, 7:26pm UTC](https://community.hubspot.com/t/submitting-data-as-an-array/80522/1 "2023-05-03T19:26:54Z")

</div>

I am using the api for submitting data to a form

### [https://api.hsforms.com/submissions/v3/integration/secure/submit/:portalId/:formGuid](https://api.hsforms.com/submissions/v3/integration/secure/submit/:portalId/:formGuid)

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”  
]  
}]  
}

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [May 4, 2023, 8:39am UTC](https://community.hubspot.com/t/submitting-data-as-an-array/80522/2 "2023-05-04T08:39:04Z")

</div>

Hello @endrits079

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

```lia-code-sample
{
 "fields": [
 {
 "name": "toa",
 "value": "true"
 },
 {
 "name": "radio",
 "value": "Option 2"
 },
 {
 "name": "multicheck",
 "value": "val3, val2, val1"
 }
 ]
}

```

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.

---

<div class="post-metadata">

**Author:** ![CRoy0](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@CRoy0](https://community.hubspot.com/u/CRoy0)\
**Post date:** [May 5, 2023, 5:44am UTC](https://community.hubspot.com/t/submitting-data-as-an-array/80522/3 "2023-05-05T05:44:03Z")

</div>

Thank you, Himanshu for sharing.

---

<div class="post-metadata">

**Author:** ![endrits079](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@endrits079](https://community.hubspot.com/u/endrits079)\
**Post date:** [May 5, 2023, 7:25am UTC](https://community.hubspot.com/t/submitting-data-as-an-array/80522/4 "2023-05-05T07:25:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [May 10, 2023, 3:50pm UTC](https://community.hubspot.com/t/submitting-data-as-an-array/80522/5 "2023-05-10T15:50:43Z")

</div>

Hi @endrits079

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:

```  
{  
“fields”: [  
{  
“name”: “toa”,  
“value”: true  
},  
{  
“name”: “radio”,  
“value”: “Option 2”  
},  
{  
“name”: “multicheck”,  
“value”: “val3,val2,val1”  
}  
]  
}  
```

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.

Thanks!
