I'm running JMeter programmatically from Java code and I'd like to generate a bunch of POST requests with a varying body. Here is a sampler I use to generate one request:
HTTPSamplerProxy sampler = new HTTPSamplerProxy();
sampler.setDomain("localhost");
sampler.setPort(8081);
sampler.setPath("/service");
sampler.setMethod("POST");
sampler.addEncodedArgument("body", "{\"key\": \"data\"}");
sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName());
How can I replace data
in the body for each request with a value from a CSV file?
I know there is CSV Data Set Config
plugin in GUI version but I haven't found a way to use it from Java code.