How to print or get the HTTP POST request body in JMETER
UseCase: I am running Jmeter from command line to generate Dashboard. For failed cases I need to capture Request Body.
One of the options would be using JSR223 PostProcessor and the following code:
log.info(sampler.getMethod() + ' ' + sampler.getUrl().toString())
sampler.getArguments().each {arg ->
log.info(arg.getStringValue())
}
It will print request method, URL and all the parameters along with values to jmeter.log file:

in case of HTTP Request sampler stands for HTTPSampleProxy, see the JavaDoc for available methods and fields and Apache Groovy - Why and How You Should Use It article to learn more about Groovy scripting in JMeter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With