Best way to dynamically fire API queries using payloads from a JSON Array?

17 views Asked by At

I need to measure the response times of an API query to different combinations of payloads.

While exploring multiple API testing tools I came across Jmeter. Which provides a CSV Data Set configuration.

Jmeter Configuration Screenshot

But what I need is selecting a random name of columns from a csv and put those is a query.

{
  "query": ["rcol1":val1, "rcol2":val2 ... ]
}

Is this achievable ?

1

There are 1 answers

1
Dmitri T On

You can build your request payload dynamically using JSR223 PreProcessor and Groovy language.

See JsonBuilder class documentation and Parsing and producing JSON article for more details.

If you want a code snippet you will need to provide:

  1. First 2-3 lines of your CSV file
  2. The desired payload format showing how data from CSV should be organized