POST method- how to dynamically pass a name value that has to be unique everytime in json


#1

I am trying to create entity, but this entity name has to be unique every time/run, otherwise it will not created. So I want to suffix with a random number, how i can do that using the Katalon tool. Is it possible? We have example for GET , I couldn’t find one for POST. Thank you


#2

Kalpana,

Parameterization technique is the same for GET and POST. You can create param in the json with ${variable} and then passing the value in the test case where calling the api


#3

Hi,
I’m having the same issue.
i would like to generate a random number at the “http body” (POST) see screen shot .
does anyone know if that is possible ?

random number .png


#4

@Eitan Nakash
One of a solutions is making random number as a variable. It meant in the HTTP Body, set the _Random as a variable, then when you call the request at test case, create a new variable and set its value to a random number, then passing it value to the request


#5

Hi
I managed to do it from the script tab.
But if would like to do it from the UI, it is not working for me yet.

The way i already did:
1. Made a new Keyword of random number generator.


2. Implement in the body ${variable1}

3. create a variable from the variable tab.
- Which type should i choose?


* I tried to use global value, but couldn’t define it as well as in this variable shown above for the same reasons
The problem is that i cant call the keyword, i have the part but cant combine them together.

Screen Shot 2018-09-20 at 10.31.18.png

Screen Shot 2018-09-20 at 10.23.35.png

Screen Shot 2018-09-20 at 10.22.19.png


#6

Your keywords is not in correct format. When you create a new keyword, there would be some examples and you need to use that format with @keyword annotation.


#7

Data type “String” is good for your case.


#8

But if would like to do it from the UI, it is not working for me yet.

It is not possible to do it directly only in the UI in one place.
You can, as previously said, use a variable (string), but u will have to set that variable to a random value yourself before calling the Send request.

And maybe you can do a Feature request in the Forum to have the possibility to use a kind of formula for the Default value for a variable (like in Excel: =Random_number() )


#9

Hi Eitan,

I was able to use variable inside HTTP Body and then used replace function to get the value from another variable in the script. See the attached screenshot for more details.

image.png


#10

hi How to pass values to ${variable} in test cases