# 400 error when submit form with an empty hutk

**URL:** <https://community.hubspot.com/t/400-error-when-submit-form-with-an-empty-hutk/47326>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [November 21, 2021, 1:47pm UTC](https://community.hubspot.com/t/400-error-when-submit-form-with-an-empty-hutk/47326 "2021-11-21T13:47:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leshapol](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leshapol/32/78471_2.png) [@leshapol](https://community.hubspot.com/u/leshapol)\
**Post date:** [November 21, 2021, 1:47pm UTC](https://community.hubspot.com/t/400-error-when-submit-form-with-an-empty-hutk/47326/1 "2021-11-21T13:47:57Z")

</div>

Hi!

I need submit data to a form.

I get the value **hutk** from cookies.

Sometimes this value is not included in cookies.  
If the request comes with an empty **hutk** , then we get a 400 error.  
The documentation says that the **hutk** value is optional, but without it, the request does not pass.

I will be grateful for help.

Where is my code:

```lia-code-sample
hutk = document.cookie.replace(
 /(?:(?:^|.*;\s*)hubspotutk\s*\=\s*([^;]*).*$)|^.*$/,
 "$1"
 );

var data = {
 fields: [
 {
 name: "firstname",
 value: firstname,
 },
 {
 name: "email",
 value: email,
 },
 {
 name: "phone",
 value: phone,
 }
 ],
 context: {
 hutk: hutk,
 pageUri: pageUri,
 pageName: page_name,
 ipAddress: ipAddress,
 },
 };

data = JSON.stringify(data);

$.ajax({
 contentType: "application/json",
 type: "POST",
 url:
 "https://api.hsforms.com/submissions/v3/integration/submit/9334399/" +
 hubspot_form_id,
 data: data,
});

```

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [November 22, 2021, 2:59pm UTC](https://community.hubspot.com/t/400-error-when-submit-form-with-an-empty-hutk/47326/2 "2021-11-22T14:59:59Z")

</div>

@leshapol ,

I would not include it at all in your json body if there is no value for it.

---

<div class="post-metadata">

**Author:** ![leshapol](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leshapol/32/78471_2.png) [@leshapol](https://community.hubspot.com/u/leshapol)\
**Post date:** [November 22, 2021, 4:39pm UTC](https://community.hubspot.com/t/400-error-when-submit-form-with-an-empty-hutk/47326/3 "2021-11-22T16:39:05Z")

</div>

It works. Thanks a lot!
