Inside a JSR223 Sampler, I am currently using setResponseData(String response) method to populate the "Response data -> Response Body" tab of a Jmeter Sampler result with some data.
Like this:
SampleResult.setResponseData(msg.getText())
This populates this section displayed in the View Results Tree listener:
I would like to also populate the "Request -> Request Body" tab of a Jmeter Sampler result viewed in the View Results Tree listener with some data, but I can't find something like SampleResult.setRequestData or setRequestBody etc...
Is there any way to do that?
SampleResult.setSamplerData() function should do the trick for you
SampleResult.setSamplerData('your custom request body')
More information on this and other JMeter API shorthands available for the JSR223 Test elements: Top 8 JMeter Java Classes You Should Be Using with Groovy