POST with references

1. Given:
URL which accepted only POST requests
POST body with elements as:

{“field1”: “field1_value”, “field2”: “field2_value”}

Many test-cases where I should use this method with different data-value for field1 and field2
2. **What am I looking for
**A possibility to use parameters or variable for POST request
For example it would be great if I could write my request as

{“field1”: {“$ref”: “Param1”}, “field2”: {“$ref”: “Param2”}}
where Param1 and Param2 some variables from test-case.

because construction “$ref” is common syntax for references in json.
https://json-spec.readthedocs.io/reference.html

3. Now I am close for writing my own method, but may be there is it something I could use for?

hi,
did you see this?
https://docs.katalon.com/display/KD/Parameterize+a+Web+Service+Object

Andrej Podhajský said:

hi,
did you see this?
https://docs.katalon.com/display/KD/Parameterize+a+Web+Service+Object

Sure i did
Could you please show me how I have to parametrized the json-body with **the variables from my test-cases?**May be I does not clarify my goal, so let me try to do it.
**1. **Lets imagine you have a web-form with about 50 filters on it. Every filter is a dropdown, or textbox, or datepicker etc.
2. Lets imagine you have to test how this form returns resulting set of values. And for doing this, you should:
2.1. test every single filter. And you should test every single filter many times.
2.2. make some searching criteria with combination of filters. And test this criteria
3. So you should create a POST request with exactly values for one or many filters and send it to server and then verify the answer.
The request could looks like this:
{…
“filter1”: “value1.1”

“filter50”: “value50.1”
}
for second test case you should use another set of values:
{…
“filter1”: “value1.2”

“filter50”: “value50.2”
}
and so on

Seems that for every test case you should create his own uniq POST request.

So I asked about functionality to parametrize the body of request like this
{…
“filter1”: ${VARIABLE_VALUE}

“filter50”: ${VARIABLE VALUE}
}
and then in every test case create a set of local variables
and then call this POST method
and then somehow initialize parameters in POST request with values of local test case variables.
See?

i don’t test this for myself yet, but from what i read, you should define variables in request object, put them in request body and then when calling request object fill those variables like e.g. in WebObject…
post body will be
{…
“filter1”: ${VARIABLE_F1}

“filter50”: ${VARIABLE_F50}
}
and call :
WS.sendRequest(findTestObject(‘New Request’, [(‘VARIABLE_F1’) : localTestCaseVariable1,(‘VARIABLE_F50’) : localTestCaseVariable50]))

P.S.: see?


image.png

image.png

. deleted duplicate image from post .

Andrej Podhajský said:

i don’t test this for myself yet, but from what i read, you should define variables in request object, put them in request body and then when calling request object fill those variables like e.g. in WebObject…
post body will be
{…
“filter1”: ${VARIABLE_F1}

“filter50”: ${VARIABLE_F50}
}
and call :
WS.sendRequest(findTestObject(‘New Request’, [(‘VARIABLE_F1’) : localTestCaseVariable1,(‘VARIABLE_F50’) : localTestCaseVariable50]))

P.S.: see?


YES!
THats exactly what I am looking for whole day long
Thanks a lot!!!