# Can't send POST data to hubspot form api using client side

**URL:** <https://community.hubspot.com/t/cant-send-post-data-to-hubspot-form-api-using-client-side/56789>\
**Category:** APIs & Integrations\
**Created:** [May 12, 2022, 6:41am UTC](https://community.hubspot.com/t/cant-send-post-data-to-hubspot-form-api-using-client-side/56789 "2022-05-12T06:41:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ablayze\_jb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ablayze_jb/32/88643_2.png) [@ablayze\_jb](https://community.hubspot.com/u/ablayze_jb)\
**Post date:** [May 12, 2022, 6:41am UTC](https://community.hubspot.com/t/cant-send-post-data-to-hubspot-form-api-using-client-side/56789/1 "2022-05-12T06:41:14Z")

</div>

![Screen Shot 2022-05-12 at 2.36.08 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/4/3482a4e2559575a7318b8612dda14b120f1b86c3.png)

Above is my code for sending form data to hubspot forms. Any idea what is the proper way to send form data to hubspot forms using client side?

---

<div class="post-metadata">

**Author:** ![miljkovicmisa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miljkovicmisa/32/86357_2.png) [@miljkovicmisa](https://community.hubspot.com/u/miljkovicmisa)\
**Post date:** [May 12, 2022, 8:18am UTC](https://community.hubspot.com/t/cant-send-post-data-to-hubspot-form-api-using-client-side/56789/2 "2022-05-12T08:18:20Z")

</div>

Hello [@ablayze\_jb](https://community.hubspot.com/t5/user/viewprofilepage/user-id/204041) . Thanks for writing. Seems like the data you send is malformed, your formStepOne variable should contain a JSON object that has the name and value for the field, where the name is the actual field name and value its value you get from the form. It should look something like the following:

```lia-code-sample
var formStepOne = {
 "fields": [
 {
 "name": "firstname",
 "value": ...
 },
 {
 "name": "lastname",
 "value": ...
 },
 ...
 ]
 }

```

Change or add the following : `contentType : 'application/json', dataType : 'json'`,  
Also add the `headers: {"Content-Type" : "application/json"}` setting.  
Hope this helps, let us know how it went and if you need more help!  
Also make sure to post the errors if you get any so it helps with debugging.  
Cheers!  
_ **If my answer was helpful please mark it as a solution.** _

---

<div class="post-metadata">

**Author:** ![ablayze\_jb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ablayze_jb/32/88643_2.png) [@ablayze\_jb](https://community.hubspot.com/u/ablayze_jb)\
**Post date:** [May 13, 2022, 2:15pm UTC](https://community.hubspot.com/t/cant-send-post-data-to-hubspot-form-api-using-client-side/56789/3 "2022-05-13T14:15:21Z")

</div>

Here’s my code but i still get an error

 ![Screen Shot 2022-05-13 at 10.09.32 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/72ac08aca468de9788c247ec0ade6ec3db7da016.png)

and for ajax on client side

 ![Screen Shot 2022-05-13 at 10.09.47 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/d/d74937b6cbb901f812201c7e93c0382667b12f45.png)

and im getting this error

 ![Screen Shot 2022-05-13 at 10.14.40 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/9/e99028cd1298ecbf841bf9e4db83d802f40b6a67.png)

---

<div class="post-metadata">

**Author:** ![miljkovicmisa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miljkovicmisa/32/86357_2.png) [@miljkovicmisa](https://community.hubspot.com/u/miljkovicmisa)\
**Post date:** [May 13, 2022, 6:17pm UTC](https://community.hubspot.com/t/cant-send-post-data-to-hubspot-form-api-using-client-side/56789/4 "2022-05-13T18:17:38Z")

</div>

Why does the error show a “GET” request? Isn’t the “POST” request the issue here?

---

<div class="post-metadata">

**Author:** ![ablayze\_jb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ablayze_jb/32/88643_2.png) [@ablayze\_jb](https://community.hubspot.com/u/ablayze_jb)\
**Post date:** [May 16, 2022, 9:28am UTC](https://community.hubspot.com/t/cant-send-post-data-to-hubspot-form-api-using-client-side/56789/5 "2022-05-16T09:28:45Z")

</div>

Its already working. i just noticed  
its  
**method: “POST” (This one works for old version of jquery)**  
should be  
**type: “POST” (For new version of jquery)**
