# Web Services- Data-driven testing

**URL:** <https://forum.katalon.com/t/web-services-data-driven-testing/41914>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [April 5, 2020, 11:30pm UTC](https://forum.katalon.com/t/web-services-data-driven-testing/41914 "2020-04-05T23:30:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssridharan](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@ssridharan](https://forum.katalon.com/u/ssridharan)\
**Post date:** [April 5, 2020, 11:30pm UTC](https://forum.katalon.com/t/web-services-data-driven-testing/41914/1 "2020-04-05T23:30:01Z")

</div>

I tried looking and could find a straight forward answer anywhere.

So here are the steps:

1. Set up a post request and link one of the property in request to a globalVariable created under variable section of the post request
2. Create a test case with “Send request and verify” this post request
3. In the body of WS.sendRequestAndVerify(findTestObject…), it will automatically show the property tied to globalVariable
4. Now I create another local variable in test case, my question is how do I link this local variable with that global Variable? or do I remove that globalVariable in the reference made under WS.sendRequestAndVerify(findTestObject…) and link local variable there? If so how, what format

E.g:  
some post request create api with body:  
{  
.   
.  
“{application}”:"${app}"  
.  
.  
}

declared under post request variable, app : globalVariable.app

Now in test case it will show:  
WS.sendRequestAndVerify(findTestObject(some create api, , [(‘app’) : GlobalVariable.app…])

since I am trying to run test case under test suite with data set, I have to define local variable in test case which maps to ‘app’. Lets say i declare it with the same name under variable, so do i enter ${app} instead of GlobalVariable.app in the body above? This doesn’t seem to work.

How are variables linked between request and test case?  
Is there a order of precedence which code checks to pick a variable?

Thanks

---

<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:** [April 6, 2020, 8:56am UTC](https://forum.katalon.com/t/web-services-data-driven-testing/41914/2 "2020-04-06T08:56:04Z")

</div>

Hi there,

You can do it like this, assuming that `tcVariable` is a test case variable

```auto
tcVariable = 
WS.sendRequestAndVerify(findTestObject(some create api, , [(‘app’) : tcVariable])

```

Which will pass the value of `tcVariable` into the request. Is this what you want ? I am kinda confused since you mentioned that

> [@ssridharan](#):
>
> since I am trying to run test case under test suite with data set, I have to define local variable in test case which maps to ‘app’

Which I take it that you’re using Data Driven testing from external data. So what do you use a global variable for in this case ?

---

<div class="post-metadata">

**Author:** ![ssridharan](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@ssridharan](https://forum.katalon.com/u/ssridharan)\
**Post date:** [April 6, 2020, 2:49pm UTC](https://forum.katalon.com/t/web-services-data-driven-testing/41914/3 "2020-04-06T14:49:47Z")

</div>

Thanks Thanh. For local testcase variable do I define it like this ?.. [(‘app’) : ${tcVariable}])…  
Do i need to remove globalVariable link in the request, for some reason it is always picking the globalVariable value instead of picking from the external data linked in test suite.

---

<div class="post-metadata">

**Author:** ![ssridharan](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@ssridharan](https://forum.katalon.com/u/ssridharan)\
**Post date:** [April 6, 2020, 3:06pm UTC](https://forum.katalon.com/t/web-services-data-driven-testing/41914/4 "2020-04-06T15:06:26Z")

</div>

Nevermind, it did pick up when local variable was linked properly. Thanks
