How to omit parameters in a REST request
Hi,
For my automation project I will have a lot of testsuites and testcases with a lot of combinations. For each testsuite I've entered the necessary parameters to be able to use in each testcase. In ReadyAPI you do that in tab "Projects" on your created webservice.
Now, not all parameters will be filled in for a particular testcase whereas the REST request will send anyways all the parameters as emtpy string.
For this project this is harmful, as an empty string could give an answer, and that isn't what I'm looking for.
For example:
Testsuite parameters: name, cbe_number, country, municipality, neighbours, street, housenumber, po_box
Testcase: Search company on name
For this testcase only parameter 'name' will be filled in, but when I send the request, all other parameters are also filled in in the URL. How can I, per testcase, omit the other parameters please?
Thanks in advance.
Couple of things:
To be able to use below groovy script, an external library is needed which can be downloaded from here and copied under READYAPI_HOME/bin/ext directory and restart the tool before running it.
Define a custom property at Project level for the service host and post details
Property name as SERVICE_HOST_PORT and value as http://localhost:8080 (or what ever)
Now coming to each test case, you may want to send certain query and header parameters.
Define custom properties at test case leve as shown below in the same notation (do not use angular brackets, just shown for separation). Also shown in the picture below.
QUERY_<parametername> and its value
HEADER_<parametername> and its value
Define as many query and header parameters as needed for the specific test.
That way, correct parameters can be identified and passed automatically under query, header sections respectively.
And now in each test case, you will only have one Groovy Script test step with above content and only custom properties are changed.
You can find the script in text format from my git
About omitting the parameters...
If a parameter with an empty value shouldn't be sent, you need to un-check the Required check-box for this parameter in the Advanced options section for this parameter.