jmahant
7 years agoOccasional Contributor
Customize the number of key value pairs in a request based on parameter value.
I have a patch request which can be used for multiple categories (as parameter) as following
PATCH {URL}/categories/<CategoryName>/values [{ "name": "<Para1_Name>", "value": "<Para1_value>" ...
- 7 years ago
I've done this but in my case it was name/value pairs in XML for a SOAP service, from your data I assume you have JSON data for a REST request.
This is just a high level overview of what I would do, all within a groovy test step before your requst test step:
- Get you JSON data from your REST request, easiest way via the GetData functionality.
- Use the JsonSlurper to convert your data to a Groovy object.
- Manipulate you data to add and remove the name value pairs via GPath expressions.
- Use the JsonOutput to convert you Groovy JSON objects back to JSON data string.
- Update your REST request with your new data.