# Parameterize a Web Service object

**URL:** <https://forum.katalon.com/t/parameterize-a-web-service-object/10924>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [May 15, 2018, 7:37am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924 "2018-05-15T07:37:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgazeaux](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgazeaux](https://forum.katalon.com/u/sgazeaux)\
**Post date:** [May 15, 2018, 7:37am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/1 "2018-05-15T07:37:42Z")

</div>

Hello,

I’m working on the automatisation API. My version of katalon is 5.4.1  
I tried to vary the body of my post with the explanation of the page if against :  
[https://docs.katalon.com/display/KD/Parameterize+a+Web+Service+object](https://docs.katalon.com/display/KD/Parameterize+a+Web+Service+object "Link: https://docs.katalon.com/display/KD/Parameterize+a+Web+Service+object")  
In my script i define :

def a = WS.sendRequest(findTestObject(‘New\_Request\_Auth’, [(email) : ‘sgappfr2@vpmel.fr’, (password) : ‘azerty!!’]))  
In the HTTP body:  
 ![](https://s3.amazonaws.com/katalon-forum/editor/64/0n07qnywpsq9.png "Image: https://s3.amazonaws.com/katalon-forum/editor/64/0n07qnywpsq9.png")  
however, the WS responds with an error, as if the parameters were not correctly sent. With the data without variables in the body the WS responds correctly.  
Help please.

[image.png](https://s3.amazonaws.com/katalon-forum/editor/64/0n07qnywpsq9.png)

---

<div class="post-metadata">

**Author:** ![duyluong](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/duyluong/32/1116_2.png) [@duyluong](https://forum.katalon.com/u/duyluong)\
**Post date:** [May 15, 2018, 8:36am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/2 "2018-05-15T08:36:15Z")

</div>

Hi [sgazeaux](http://forum.katalon.com/profile/7043/sgazeaux),  
Maybe your script’s syntax is incorrect.  
Please try:

```auto
def a = WS.sendRequest(findTestObject('New_Request_Auth', ['email' : 'sgappfr2@vpmel.fr', 'password' : 'azerty!!']))

```

instead of

```auto
def a = WS.sendRequest(findTestObject('New_Request_Auth', [(email) : 'sgappfr2@vpmel.fr', (password) : 'azerty!!']))

```

Thanks.

---

<div class="post-metadata">

**Author:** ![sgazeaux](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgazeaux](https://forum.katalon.com/u/sgazeaux)\
**Post date:** [May 15, 2018, 9:24am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/3 "2018-05-15T09:24:48Z")

</div>

Hello duyluong,

Thanks for your answer, but it is the same error with your syntax. This syntax is generated automatically in the script when I insert object parameters in The objectPost  
 ![](https://s3.amazonaws.com/katalon-forum/editor/w6/0js7dybfnwsd.jpg "Image: https://s3.amazonaws.com/katalon-forum/editor/w6/0js7dybfnwsd.jpg")

I don’t understand what could be the problem.

Thanks for you help

[Test Object Input.jpg](https://s3.amazonaws.com/katalon-forum/editor/w6/0js7dybfnwsd.jpg)

---

<div class="post-metadata">

**Author:** ![Kavia](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kavia](https://forum.katalon.com/u/Kavia)\
**Post date:** [May 15, 2018, 12:34pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/4 "2018-05-15T12:34:46Z")

</div>

Hi All,

Can any one got the solution for the issue reported by [![sgazeaux](https://secure.gravatar.com/avatar/d9c04bef1565f2e5f1d3098cac9a7c12?s=96&d=mm&r=g "Image: https://secure.gravatar.com/avatar/d9c04bef1565f2e5f1d3098cac9a7c12?s=96&d=mm&r=g")](http://forum.katalon.com/profile/7043/sgazeaux "Link: http://forum.katalon.com/profile/7043/sgazeaux")

Please let us know one we solved above issue. Currently we too facing the same issue

Thanks & Regards

---

<div class="post-metadata">

**Author:** ![John\_Paul](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@John\_Paul](https://forum.katalon.com/u/John_Paul)\
**Post date:** [May 15, 2018, 3:48pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/5 "2018-05-15T15:48:50Z")

</div>

Try putting quotes around your parameters in your JSON i.e. “${email}” and “${password}” the parameters work like macro-substitution. You still need the quotes. (I think)

---

<div class="post-metadata">

**Author:** ![Kavia](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kavia](https://forum.katalon.com/u/Kavia)\
**Post date:** [May 16, 2018, 7:53am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/6 "2018-05-16T07:53:05Z")

</div>

Hi John,

Thanks for acknowledged, but still its not solving the problem. If you have any idea how to resolve, please help me out here

Calling statement:

def responseRetriveContactDetails = WS.sendRequest(findTestObject(‘RetrivePersonDetails’, [(‘contactURN’) : customerURN]))

In SoapUI request:

I have used in below format

v11:personIdentity${contactURN}\</v11:personIdentity\>

During execution, contactURN value still not passing.

---

<div class="post-metadata">

**Author:** ![sgazeaux](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgazeaux](https://forum.katalon.com/u/sgazeaux)\
**Post date:** [May 16, 2018, 11:49am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/7 "2018-05-16T11:49:11Z")

</div>

Hello John Paul,

Effectively, when I’m putting quotes in the parameters, i’ts ok ! That is the solution.  
Thanks a lot John !

Best Regard.

---

<div class="post-metadata">

**Author:** ![Kavia](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kavia](https://forum.katalon.com/u/Kavia)\
**Post date:** [May 16, 2018, 12:50pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/8 "2018-05-16T12:50:27Z")

</div>

Hi Sgazeaux,

Can you help me on how to store specific attribute in variable from JSON

def response = WS.sendRequest(findTestObject(‘REST\_CommentDetails’))

def responseCode = response.getStatusCode()

println('Response Code: ’ + responseCode)

// respone body

def responseText = response.getResponseText()

println('Response body: ’ + responseText)

def jsonObject = new groovy.json.JsonSlurper().parseText(responseText)

Getting error on below line  
println(jsonObject.[0].name)

---

<div class="post-metadata">

**Author:** ![sgazeaux](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgazeaux](https://forum.katalon.com/u/sgazeaux)\
**Post date:** [May 16, 2018, 1:26pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/9 "2018-05-16T13:26:12Z")

</div>

If you get a error on print line, check your path on [http://jsonpath.com/](http://jsonpath.com/) website  
I’m not sure that the [0] position is necessary, make sure that is ok.

---

<div class="post-metadata">

**Author:** ![Kavia](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kavia](https://forum.katalon.com/u/Kavia)\
**Post date:** [May 16, 2018, 2:05pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/10 "2018-05-16T14:05:26Z")

</div>

Hi Sgazeaux,

Thanks for great help!!

Can you please clarify me on below query at last

Code:

String Email= jsonObject.email[0]+“Lucky”

println(Email)

// Try to post updated email and view response

def responsePost = WS.sendRequest(findTestObject(‘PostUpdatedEmail’, [‘email’ : Email]))

def responseTextPost = responsePost.getResponseText()

println('Response body: ’ + responseTextPost)

JSON:

{

```
"postId": 2,

"id": 6,

"name": "et fugit eligendi deleniti quidem qui sint nihil autem",

"email": "${email}",

"body": "doloribus at sed quis culpa deserunt consectetur qui praesentium\\naccusamus fugiat dicta\\nvoluptatem rerum ut voluptate autem\\nvoluptatem repellendus aspernatur dolorem in"

```

}

But here when I trigger my code, am unable to pass Email to email attribute mentioned JSON.

It would great helpful us if you provide solution

---

<div class="post-metadata">

**Author:** ![John\_Paul](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@John\_Paul](https://forum.katalon.com/u/John_Paul)\
**Post date:** [May 16, 2018, 7:52pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/11 "2018-05-16T19:52:01Z")

</div>

Hi Kavia. When you are loading the test object, try: findTestObject(‘PostUpdatedEmail’, [(email) : Email]) instead of findTestObject(‘PostUpdatedEmail’, [‘email’ : Email])

---

<div class="post-metadata">

**Author:** ![Kavia](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kavia](https://forum.katalon.com/u/Kavia)\
**Post date:** [May 17, 2018, 1:19pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/12 "2018-05-17T13:19:43Z")

</div>

Hi John,

// Try to post updated email and view response

def responsePost = WS.sendRequest(findTestObject(‘PostUpdatedEmail’, [(email) : Email]))

def responseTextPost = responsePost.getResponseText()

println('Response body: ’ + responseTextPost)

Code:

When I run getting below error message

// Try to post updated email and view response

def responsePost = WS.sendRequest(findTestObject(‘PostUpdatedEmail’, [(email) : Email]))

def responseTextPost = responsePost.getResponseText()

println('Response body: ’ + responseTextPost)

JSON:

{

```
"postId": 2,

"id": 6,

"name": "et fugit eligendi deleniti quidem qui sint nihil autem",

"email": "${email}",

"body": "doloribus at sed quis culpa deserunt consectetur qui praesentium\\naccusamus fugiat dicta\\nvoluptatem rerum ut voluptate autem\\nvoluptatem repellendus aspernatur dolorem in"

```

}

Getting below error message

[ERROR] - Test Cases/DemoRestAutomation FAILED because (of) Variable ‘email’ is not defined for test case.

If I define Variable eamil inside test case as well, actual value not passing

---

<div class="post-metadata">

**Author:** ![John\_Paul](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@John\_Paul](https://forum.katalon.com/u/John_Paul)\
**Post date:** [May 17, 2018, 4:43pm UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/13 "2018-05-17T16:43:59Z")

</div>

Variables are case sensitive. While in your test object you are passing the variable _EMail_, your error indicates the variable \_email. \_Could you be dealing with two different variables here?

---

<div class="post-metadata">

**Author:** ![Kavia](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kavia](https://forum.katalon.com/u/Kavia)\
**Post date:** [May 18, 2018, 7:30am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/14 "2018-05-18T07:30:12Z")

</div>

Hi John,

Still we are facing same problem, After changing variable name as well

Code:

/ Try to post updated email and view response

def responsePost = WS.sendRequest(findTestObject(‘PostUpdatedEmail’, [(Email) : Email]))

def responseTextPost = responsePost.getResponseText()

println('Response body: ’ + responseTextPost)

JSON:

{

```
"postId": 2,

"id": 6,

"name": "et fugit eligendi deleniti quidem qui sint nihil autem",

"email": "${Email}",

"body": "doloribus at sed quis culpa deserunt consectetur qui praesentium\\naccusamus fugiat dicta\\nvoluptatem rerum ut voluptate autem\\nvoluptatem repellendus aspernatur dolorem in"

```

}

Email variable value still not passing

---

<div class="post-metadata">

**Author:** ![Kavia](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kavia](https://forum.katalon.com/u/Kavia)\
**Post date:** [May 28, 2018, 10:46am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/15 "2018-05-28T10:46:46Z")

</div>

> > [Kavia](https://forum.katalon.com/profile/7048/Kavia) said:
> > 
> > Hi John,
> > 
> > Still we are facing same problem, After changing variable name as well
> > 
> > Code:
> > 
> > / Try to post updated email and view response
> > 
> > def responsePost = WS.sendRequest(findTestObject(‘PostUpdatedEmail’, [(Email) : Email]))
> > 
> > def responseTextPost = responsePost.getResponseText()
> > 
> > println('Response body: ’ + responseTextPost)
> > 
> > JSON:
> > 
> > {
> > 
> > ```
> > "postId": 2,
> > 
> > "id": 6,
> > 
> > "name": "et fugit eligendi deleniti quidem qui sint nihil autem",
> > 
> > "email": "${Email}",
> > 
> > "body": "doloribus at sed quis culpa deserunt consectetur qui praesentium\\naccusamus fugiat dicta\\nvoluptatem rerum ut voluptate autem\\nvoluptatem repellendus aspernatur dolorem in"
> > 
> > ```
> > 
> > }
> > 
> > Email variable value still not passing
> 
> Can any body have the answer for Query?

---

<div class="post-metadata">

**Author:** ![Brylesu](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Brylesu](https://forum.katalon.com/u/Brylesu)\
**Post date:** [September 1, 2022, 2:12am UTC](https://forum.katalon.com/t/parameterize-a-web-service-object/10924/16 "2022-09-01T02:12:37Z")

</div>

Is there already solution for this?  
Im having the same problem
