# Right way to use variable

**URL:** <https://forum.katalon.com/t/right-way-to-use-variable/44181>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [June 4, 2020, 2:52pm UTC](https://forum.katalon.com/t/right-way-to-use-variable/44181 "2020-06-04T14:52:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gan\_Jyi\_Yng](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/gan_jyi_yng/32/16104_2.png) [@Gan\_Jyi\_Yng](https://forum.katalon.com/u/Gan_Jyi_Yng)\
**Post date:** [June 4, 2020, 2:52pm UTC](https://forum.katalon.com/t/right-way-to-use-variable/44181/1 "2020-06-04T14:52:37Z")

</div>

I’m using variable in this way and I found it is very tedious to input the string at many places.  
Please advise or correct me if I can work in better way.

Example:  
At profile,  
Add url, value [www.test.com](http://www.test.com)  
Add testid, value empty

Object for POST endpoint  
Http://${url}/test/${testid}

At the object variable tab  
Add url, set to global variable, select the value which set at profile.  
Add testid, set to string, select the value empty.

Test case to call the object  
def testid = test123  
def callpost = WS.sendRequestAndVerify(findTestObject(‘Object Repository/post’, [(‘testid’) : testid, (‘url’) : GlobalVariable.url]))

---

<div class="post-metadata">

**Author:** ![huynguyen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/huynguyen/32/552_2.png) [@huynguyen](https://forum.katalon.com/u/huynguyen)\
**Post date:** [June 5, 2020, 5:13pm UTC](https://forum.katalon.com/t/right-way-to-use-variable/44181/2 "2020-06-05T17:13:41Z")

</div>

Hi @Gan_Jyi_Yng,  
You can set http://${GlobalVariable.url}/test/${GlobalVariable.testid}.

---

<div class="post-metadata">

**Author:** ![Gan\_Jyi\_Yng](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/gan_jyi_yng/32/16104_2.png) [@Gan\_Jyi\_Yng](https://forum.katalon.com/u/Gan_Jyi_Yng)\
**Post date:** [June 8, 2020, 12:55am UTC](https://forum.katalon.com/t/right-way-to-use-variable/44181/3 "2020-06-08T00:55:12Z")

</div>

once i set this  
http://${GlobalVariable.url}/test/${GlobalVariable.testid}.

i do not need to input them at object variable tab?

but i still need them in profile?

what about test case when calling the object, am i need to input variable like this?  
WS.sendRequestAndVerify(findTestObject(‘Object Repository/post’, [(‘testid’) : testid, (‘url’) : GlobalVariable.url]))

---

<div class="post-metadata">

**Author:** ![huynguyen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/huynguyen/32/552_2.png) [@huynguyen](https://forum.katalon.com/u/huynguyen)\
**Post date:** [June 8, 2020, 4:52pm UTC](https://forum.katalon.com/t/right-way-to-use-variable/44181/4 "2020-06-08T16:52:23Z")

</div>

Hi @Gan_Jyi_Yng,  
Once you set as my instruction, you do not need to input your variables at object variable tab. Of course, you will need your variables to be defined in a profile. Also, in your test script, you don’t need to input the variables anymore.
