# Getting 400 Bad Request if using variables, but fine with hard coded values

**URL:** <https://forum.katalon.com/t/getting-400-bad-request-if-using-variables-but-fine-with-hard-coded-values/134895>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [June 17, 2024, 2:17am UTC](https://forum.katalon.com/t/getting-400-bad-request-if-using-variables-but-fine-with-hard-coded-values/134895 "2024-06-17T02:17:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![syerra.sunil](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/syerra.sunil/32/23870_2.png) [@syerra.sunil](https://forum.katalon.com/u/syerra.sunil)\
**Post date:** [June 17, 2024, 2:17am UTC](https://forum.katalon.com/t/getting-400-bad-request-if-using-variables-but-fine-with-hard-coded-values/134895/1 "2024-06-17T02:17:47Z")

</div>

I m able to PUT the HTTP request when i m using had coded values.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/0/a/0a4495d234802c546bde27284f5ec939f2ea6caa.png)

But getting 400 Bad request if i m using variable to replace the hard coded value with dynamic value.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/c/d/cd65fe88741c921f009cd2a52c214b90944ee549.png)

Note : For the bad request we are getting below error at the backend

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [June 17, 2024, 2:17am UTC](https://forum.katalon.com/t/getting-400-bad-request-if-using-variables-but-fine-with-hard-coded-values/134895/2 "2024-06-17T02:17:47Z")

</div>

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [June 17, 2024, 2:20am UTC](https://forum.katalon.com/t/getting-400-bad-request-if-using-variables-but-fine-with-hard-coded-values/134895/3 "2024-06-17T02:20:52Z")

</div>

Hi @syerra.sunil,

Welcome to our community. I have found this guide doc on your issue: [https://docs.katalon.com/katalon-studio/data-driven-testing/data-driven-testing-with-restful-web-service-requests#create-web-service-request-objects-with-variables](https://docs.katalon.com/katalon-studio/data-driven-testing/data-driven-testing-with-restful-web-service-requests#create-web-service-request-objects-with-variables). Please take a look

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [June 17, 2024, 7:38am UTC](https://forum.katalon.com/t/getting-400-bad-request-if-using-variables-but-fine-with-hard-coded-values/134895/4 "2024-06-17T07:38:29Z")

</div>

Hi there @syerra.sunil, 👋

Welcome to our forum.

Please take a look at the documentation that Elly proposed.

If the issue persists, then please feel free to seek out support in our **Ask Katalon Anything thread** below 👇

> [@\[AKA Jun '24\] Katalon Studio | Integrations | Web/API/Mobile Testing speech\_balloon](http://forum.katalon.com/t/aka-jun-24-katalon-studio-integrations-web-api-mobile-testing/131706):
>
> [[Main Social]](http://forum.katalon.com/t/ask-katalon-anything-june-2024/131701) Hi folks, wave Once again, we are thrilled to welcome you to our Ask Katalon Anything activity where you can ask our team about anything Katalon-related, from tips, tricks, and best practices when testing with the Katalon Platform, to industry and general questions, you name it. Within this thread, you will be able to ask our [KShare](http://forum.katalon.com/docs?ascending=false&solved=false&tags=support) contributors (from our Product Support team) about the following topics: Katalon Studio (and more specifically Integrations & Setup) Web Testing …

---

<div class="post-metadata">

**Author:** ![depapp](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/depapp/32/29178_2.png) [@depapp](https://forum.katalon.com/u/depapp)\
**Post date:** [October 9, 2026, 9:28am UTC](https://forum.katalon.com/t/getting-400-bad-request-if-using-variables-but-fine-with-hard-coded-values/134895/5 "2026-10-09T09:28:17Z")

</div>

hi @syerra.sunil

the backend already told you what is wrong: “illegal unquoted character (CTRL-CHAR, code 10)”. code 10 is a line feed. so the value katalon put into the body has a newline inside it, the hard coded one does not.

usual sources: the default value in the variables tab was pasted with a trailing enter, the value comes from an excel or csv cell with a line break, or it was built with a groovy triple quote string. quick check, in the verification tab of the request:

```groovy
println request.getBodyContent().getText().inspect()

```

inspect() shows the \n explicitly. then fix it at the source, or strip it when you pass the variable, e.g. `WS.sendRequest(findTestObject('API/PutThing', [id: myId.trim()]))`. if the value legitimately has line breaks (an address, a note), the json needs it escaped as \n, so pass it through `JsonOutput.toJson(value)` and drop the quotes around ${var} in the body.
