# Get JSON request body

**URL:** <https://forum.katalon.com/t/get-json-request-body/54901>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [May 18, 2021, 1:17pm UTC](https://forum.katalon.com/t/get-json-request-body/54901 "2021-05-18T13:17:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![SouthAsianNobleman](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/southasiannobleman/32/16103_2.png) [@SouthAsianNobleman](https://forum.katalon.com/u/SouthAsianNobleman)\
**Post date:** [May 18, 2021, 1:17pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/1 "2021-05-18T13:17:32Z")

</div>

I want to know if there is any other way to store httpbody in variable since getHttpBody() is deprecated after 5.5. in my case, i want to get the request body in json string for later use in authentication things, any suggest ? cant find the related one at latest api doc, thanks before

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [May 18, 2021, 1:24pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/2 "2021-05-18T13:24:49Z")

</div>

> [@SouthAsianNobleman](#):
>
> since getHttpBody() is deprecated after 5.5

What do you mean by this?  
Please point me to the URL where you read it.

---

<div class="post-metadata">

**Author:** ![SouthAsianNobleman](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/southasiannobleman/32/16103_2.png) [@SouthAsianNobleman](https://forum.katalon.com/u/SouthAsianNobleman)\
**Post date:** [May 18, 2021, 1:53pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/3 "2021-05-18T13:53:18Z")

</div>

![image](https://europe1.discourse-cdn.com/katalon/original/3X/4/f/4fa946ad249eab03fe974daf05f981b33eaf44ed.png)

short story is, i want to get the API request body as json string and store it in some variable before hitting the API request, now i can use getHttpBody() which is return json request body as string, but the IDE says its deprecated, is there any new solution related for my case ? thanks

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [May 18, 2021, 1:56pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/4 "2021-05-18T13:56:32Z")

</div>

API doc is here:  
[https://docs.katalon.com/javadoc/com/kms/katalon/core/testobject/RequestObject.html#getHttpBody()](https://docs.katalon.com/javadoc/com/kms/katalon/core/testobject/RequestObject.html#getHttpBody())

---

<div class="post-metadata">

**Author:** ![SouthAsianNobleman](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/southasiannobleman/32/16103_2.png) [@SouthAsianNobleman](https://forum.katalon.com/u/SouthAsianNobleman)\
**Post date:** [May 18, 2021, 2:02pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/5 "2021-05-18T14:02:39Z")

</div>

Hmmm seems like not related with my case, i just want to get the request body not setting the body content, anyway thanks with the answer, i think i will stick with the Deprecated method one

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [May 18, 2021, 2:09pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/6 "2021-05-18T14:09:20Z")

</div>

> [@SouthAsianNobleman](#):
>
> not setting the body content,

I think you were confused by a mistake in the doc:

> Please use [setBodyContent(HttpBodyContent)](https://docs.katalon.com/javadoc/com/kms/katalon/core/testobject/RequestObject.html#setBodyContent(com.kms.katalon.core.testobject.HttpBodyContent)) instead.

This sentence must be a mistake.

You would want to look at [RequestObject::getBodyContent](https://docs.katalon.com/javadoc/com/kms/katalon/core/testobject/RequestObject.html#getBodyContent())

@ThanhTo  
I think that the API doc requires a correction.

---

<div class="post-metadata">

**Author:** ![SouthAsianNobleman](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/southasiannobleman/32/16103_2.png) [@SouthAsianNobleman](https://forum.katalon.com/u/SouthAsianNobleman)\
**Post date:** [May 18, 2021, 2:23pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/7 "2021-05-18T14:23:06Z")

</div>

LOL you’re right, thanks for the solution, now it works like a charm, just had to put it at HttpTextBodyContent since it implemented Interfaces and Traits of HttpBodyContent

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/f/7/f7d24d0af89280165fc412d7a5d266efe85c72ba.png)  
The solution become like this, in case someone had the same problem with me, this is my solution

anyway thanks again for the help @kazurayam 😁

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [May 18, 2021, 2:40pm UTC](https://forum.katalon.com/t/get-json-request-body/54901/8 "2021-05-18T14:40:30Z")

</div>

Assigned @Shin on May 18, 2021, 2:40pm UTC



---

<div class="post-metadata">

**Author:** ![nafi.konsultan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/nafi.konsultan/32/20464_2.png) [@nafi.konsultan](https://forum.katalon.com/u/nafi.konsultan)\
**Post date:** [October 13, 2022, 3:34am UTC](https://forum.katalon.com/t/get-json-request-body/54901/9 "2022-10-13T03:34:46Z")

</div>

i got the same constraint as you, i want to get request body in json string to use later in authentication. but the output that comes out is the body of the response, not the body of the request

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/2/5/25b5312a34ed68769b64c7b81b15fdb188c3ea50.png)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 13, 2022, 4:07am UTC](https://forum.katalon.com/t/get-json-request-body/54901/11 "2022-10-13T04:07:24Z")

</div>

> [@nafi.konsultan](#):
>
> a script error

What the error message said? Please share the log to us.

---

<div class="post-metadata">

**Author:** ![nafi.konsultan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/nafi.konsultan/32/20464_2.png) [@nafi.konsultan](https://forum.katalon.com/u/nafi.konsultan)\
**Post date:** [October 13, 2022, 4:35am UTC](https://forum.katalon.com/t/get-json-request-body/54901/12 "2022-10-13T04:35:21Z")

</div>

oh sorry there is no error, but the output that appears is the body response, not the body request as I wanted

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 13, 2022, 4:55am UTC](https://forum.katalon.com/t/get-json-request-body/54901/13 "2022-10-13T04:55:04Z")

</div>

> [@nafi.konsultan](#):
>
> the output that appears is the body response, not the body request as I wanted

Of course, the output will be the body of the response because your code tells to get body content of the variable named **response**.  
 ![スクリーンショット 2022-10-13 13.53.36](https://europe1.discourse-cdn.com/katalon/original/3X/9/2/9297aa32f04ca7a1f0ba64c107a780ae6ace43ed.png)

Do you want to look at the request?  
Then should write your code to do that.

---

<div class="post-metadata">

**Author:** ![nafi.konsultan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/nafi.konsultan/32/20464_2.png) [@nafi.konsultan](https://forum.katalon.com/u/nafi.konsultan)\
**Post date:** [October 13, 2022, 6:10am UTC](https://forum.katalon.com/t/get-json-request-body/54901/14 "2022-10-13T06:10:58Z")

</div>

then how can I get the request body from the object repository that I will hit?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 13, 2022, 8:33am UTC](https://forum.katalon.com/t/get-json-request-body/54901/15 "2022-10-13T08:33:40Z")

</div>

@nafi.konsultan

You haven’t explained your problem enough.

Please follow the following guidance.

> [@\[TIP\] How To Help Us Help You!](http://forum.katalon.com/t/tip-how-to-help-us-help-you/12919):
>
> My test is BROKEN! NOTHING WORKS! HELP ME! Relax. We get it. We really do. There are some pretty smart and clever people on this forum, but you must realize, they are not magicians or wizards or gods. They cannot see your code, they can’t see your errors and they don’t even know what your AUT is meant to do even though it might seem perfectly obvious to you. So please relax and follow the advice below, before you start writing your post. The advice below will tell you the exact information …

You had better create a new post on your own and provide enough information to us.
