# Is this possible to pass dynamic elements in HTTP body in Object repository from Data Files?

**URL:** <https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [March 8, 2018, 5:59am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662 "2018-03-08T05:59:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganesh1](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Ganesh1](https://forum.katalon.com/u/Ganesh1)\
**Post date:** [March 8, 2018, 5:59am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/1 "2018-03-08T05:59:46Z")

</div>

![](https://s3.amazonaws.com/katalon-forum/editor/3i/i1jhs8n758d7.png)

[KatalonObj.png](https://s3.amazonaws.com/katalon-forum/editor/3i/i1jhs8n758d7.png)

---

<div class="post-metadata">

**Author:** ![Trong\_Bui](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/trong_bui/32/374_2.png) [@Trong\_Bui](https://forum.katalon.com/u/Trong_Bui)\
**Post date:** [March 8, 2018, 6:46am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/2 "2018-03-08T06:46:16Z")

</div>

you could replace the text with ${variale\_name}, and then in the test case, if you have a parameter having the same ‘variable\_name’, its value will be passed into the body.

---

<div class="post-metadata">

**Author:** ![Ganesh1](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Ganesh1](https://forum.katalon.com/u/Ganesh1)\
**Post date:** [March 8, 2018, 9:44am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/3 "2018-03-08T09:44:11Z")

</div>

Thanks much for the support, I have done in the same way but it’s not working! Could you please share me the screens?

---

<div class="post-metadata">

**Author:** ![Trong\_Bui](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/trong_bui/32/374_2.png) [@Trong\_Bui](https://forum.katalon.com/u/Trong_Bui)\
**Post date:** [March 9, 2018, 3:18am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/4 "2018-03-09T03:18:28Z")

</div>

Ganesh,

Sorry for my bad. We supported feature in WebElement Object and planned for doing the same with Webservice Object so I misunderstood that it was implemeted. However, the feature will be included in the release 5.4 within the next 2-3 weeks.

---

<div class="post-metadata">

**Author:** ![Ganesh1](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Ganesh1](https://forum.katalon.com/u/Ganesh1)\
**Post date:** [March 9, 2018, 7:15am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/5 "2018-03-09T07:15:44Z")

</div>

Great! It will be good if I get this in the planned release 5.4

---

<div class="post-metadata">

**Author:** ![Francois\_Grossin](https://avatars.discourse-cdn.com/v4/letter/f/e0b2c6/32.png) [@Francois\_Grossin](https://forum.katalon.com/u/Francois_Grossin)\
**Post date:** [March 15, 2018, 1:44pm UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/6 "2018-03-15T13:44:31Z")

</div>

This is a great news ! I can do all this using code but other member of my team do not have coding skills and it will be very nice for them to use Object parameters on Web Service Objects  
Thanks !!!

---

<div class="post-metadata">

**Author:** ![bernard](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bernard](https://forum.katalon.com/u/bernard)\
**Post date:** [March 19, 2018, 12:59pm UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/7 "2018-03-19T12:59:41Z")

</div>

Yes, it is possible.

Dont forget to include :  
import com.kms.katalon.core.testobject.ResponseObject  
import com.kms.katalon.core.testobject.RequestObject

create an RequestObject inside Object repository  
then, add an HTTP Body request like with parameters you want (like ${name})  
with object in Test case, write these lines :

//variables declarations  
RequestObject request  
ResponseObject reponse

//HTTP Body Request to be replace  
String vsRequestBody = ‘’;

//Get the request objet in Object Repository and cast then into RequestObject  
request = (RequestObject)findTestObject(‘AuthenticationServiceBinding’)

//Get request HTTP Body  
vsRequestBody = request.getHttpBody();

//Replace dynamics parameters  
vsRequestBody = vsRequestBody.replace(’${name}’, …your value…);

//Set the new request HTTP Body  
request.setHttpBody(vsRequestBody);

//Executing the new Request object  
reponse = WS.sendRequest(request);

…and that’s all

Please Katalon developpers, could you do it with parameters interfaces ?

Have a good day

---

<div class="post-metadata">

**Author:** ![Ganesh1](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Ganesh1](https://forum.katalon.com/u/Ganesh1)\
**Post date:** [March 20, 2018, 8:59am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/8 "2018-03-20T08:59:37Z")

</div>

> bernard said:
> 
> Yes, it is possible.
> 
> Dont forget to include :  
> import com.kms.katalon.core.testobject.ResponseObject  
> import com.kms.katalon.core.testobject.RequestObject
> 
> create an RequestObject inside Object repository  
> then, add an HTTP Body request like with parameters you want (like ${name})  
> with object in Test case, write these lines :
> 
> //variables declarations  
> RequestObject request  
> ResponseObject reponse
> 
> //HTTP Body Request to be replace  
> String vsRequestBody = ‘’;
> 
> //Get the request objet in Object Repository and cast then into RequestObject  
> request = (RequestObject)findTestObject(‘AuthenticationServiceBinding’)
> 
> //Get request HTTP Body  
> vsRequestBody = request.getHttpBody();
> 
> //Replace dynamics parameters  
> vsRequestBody = vsRequestBody.replace(‘${name}’, …your value…);
> 
> //Set the new request HTTP Body  
> request.setHttpBody(vsRequestBody);
> 
> //Executing the new Request object  
> reponse = WS.sendRequest(request);
> 
> …and that’s all
> 
> Please Katalon developpers, could you do it with parameters interfaces ?
> 
> Have a good day

Hi Bernard have u read the title of this post??

Code wise we can achieve!

As katalon studio claims that the tool is for non-techie users also! we need to seek in this aspect also.

---

<div class="post-metadata">

**Author:** ![bernard](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bernard](https://forum.katalon.com/u/bernard)\
**Post date:** [March 20, 2018, 12:42pm UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/9 "2018-03-20T12:42:55Z")

</div>

> Ganesh said:
> 
> Hi Bernard have u read the title of this post??
> 
> Code wise we can achieve!
> 
> As katalon studio claims that the tool is for non-techie users also! we need to seek in this aspect also.

Of course, I’ve read it…for remember : “Is this possible to pass dynamic elements in HTTP body in Object repository from Data Files??”

As Katalon does not provide functionnal issue until the next feature, i gave a technical solution with Test Case…issue that works well.

But…I will be happy to have a non-technie user solution (2 or 3 week to wait since 09 March 2018)

---

<div class="post-metadata">

**Author:** ![Ganesh1](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Ganesh1](https://forum.katalon.com/u/Ganesh1)\
**Post date:** [March 21, 2018, 4:24am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/10 "2018-03-21T04:24:38Z")

</div>

> bernard said:
> 
> But…I will be happy to have a non-technie user solution (2 or 3 week to wait since 09 March 2018)

That’s the true story that we really wanted we will see the same in the Future releases!

Cheers!

---

<div class="post-metadata">

**Author:** ![Nilesh\_Devgirikar](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@Nilesh\_Devgirikar](https://forum.katalon.com/u/Nilesh_Devgirikar)\
**Post date:** [July 5, 2018, 1:30pm UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/11 "2018-07-05T13:30:19Z")

</div>

> [Trong Bui](https://forum.katalon.com/profile/1408/Trong%20Bui) said:
> 
> you could replace the text with ${variale\_name}, and then in the test case, if you have a parameter having the same ‘variable\_name’, its value will be passed into the body.

Can you explain more on able solution please …by giving example.

In our application “token” is passed in the json body token " : “####9999323” . How can i replace dynamic token in the body and make request with updated body.

Please please give me solution

---

<div class="post-metadata">

**Author:** ![Nilesh\_Devgirikar](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@Nilesh\_Devgirikar](https://forum.katalon.com/u/Nilesh_Devgirikar)\
**Post date:** [July 5, 2018, 1:57pm UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/12 "2018-07-05T13:57:58Z")

</div>

> bernard said:
> 
> Yes, it is possible.
> 
> Dont forget to include :  
> import com.kms.katalon.core.testobject.ResponseObject  
> import com.kms.katalon.core.testobject.RequestObject
> 
> create an RequestObject inside Object repository  
> then, add an HTTP Body request like with parameters you want (like ${name})  
> with object in Test case, write these lines :
> 
> //variables declarations  
> RequestObject request  
> ResponseObject reponse
> 
> //HTTP Body Request to be replace  
> String vsRequestBody = ‘’;
> 
> //Get the request objet in Object Repository and cast then into RequestObject  
> request = (RequestObject)findTestObject(‘AuthenticationServiceBinding’)
> 
> //Get request HTTP Body  
> vsRequestBody = request.getHttpBody();
> 
> //Replace dynamics parameters  
> vsRequestBody = vsRequestBody.replace(‘${name}’, …your value…);
> 
> //Set the new request HTTP Body  
> request.setHttpBody(vsRequestBody);
> 
> //Executing the new Request object  
> reponse = WS.sendRequest(request);
> 
> …and that’s all
> 
> Please Katalon developpers, could you do it with parameters interfaces ?
> 
> Have a good day

> bernard said:
> 
> Yes, it is possible.
> 
> Dont forget to include :  
> import com.kms.katalon.core.testobject.ResponseObject  
> import com.kms.katalon.core.testobject.RequestObject
> 
> create an RequestObject inside Object repository  
> then, add an HTTP Body request like with parameters you want (like ${name})  
> with object in Test case, write these lines :
> 
> //variables declarations  
> RequestObject request  
> ResponseObject reponse
> 
> //HTTP Body Request to be replace  
> String vsRequestBody = ‘’;
> 
> //Get the request objet in Object Repository and cast then into RequestObject  
> request = (RequestObject)findTestObject(‘AuthenticationServiceBinding’)
> 
> //Get request HTTP Body  
> vsRequestBody = request.getHttpBody();
> 
> //Replace dynamics parameters  
> vsRequestBody = vsRequestBody.replace(‘${name}’, …your value…);
> 
> //Set the new request HTTP Body  
> request.setHttpBody(vsRequestBody);
> 
> //Executing the new Request object  
> reponse = WS.sendRequest(request);
> 
> …and that’s all
> 
> Please Katalon developpers, could you do it with parameters interfaces ?
> 
> Have a good day

Your solution is not working …i implemented as it is …but not working please help

RequestObject request

//HTTP Body Request to be replace

String vsRequestBody = ‘’;

request = (RequestObject)findTestObject(‘VAM/Login’)

vsRequestBody = request.getHttpBody()

System.out.println(vsRequestBody)

vsRequestBody = vsRequestBody.replace(‘${Token}’,‘KKKKK’)

vsRequestBody = request.setHttpBody(vsRequestBody);

System.out.println(vsRequestBody)

Printing : null on the console

---

<div class="post-metadata">

**Author:** ![Balraj\_Alladi](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Balraj\_Alladi](https://forum.katalon.com/u/Balraj_Alladi)\
**Post date:** [October 17, 2018, 7:02pm UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/13 "2018-10-17T19:02:13Z")

</div>

Hi Bernard,

I followed the same steps as you said and it is working for me. See screenshot for more details. Thanks to Bernard.

![](https://s3.amazonaws.com/katalon-forum/editor/k0/1zfb9osxlbwl.png)

[image.png](https://s3.amazonaws.com/katalon-forum/editor/k0/1zfb9osxlbwl.png)

---

<div class="post-metadata">

**Author:** ![Yosepina](https://avatars.discourse-cdn.com/v4/letter/y/fbc32d/32.png) [@Yosepina](https://forum.katalon.com/u/Yosepina)\
**Post date:** [May 13, 2019, 2:02am UTC](https://forum.katalon.com/t/is-this-possible-to-pass-dynamic-elements-in-http-body-in-object-repository-from-data-files/9662/14 "2019-05-13T02:02:12Z")

</div>

hallo Mr. Balraj,

can you explain, how it works on you? because i have the same issue. and where the body you make ? thankyou
