printing "bodyString.saveAs" with a custom function

@Stéphane Landelle

In the following example, I have two api calls covered. I wanted to print the response of each api call in the logs but don’t want to duplicate writing the same code. I understand enabling <!-- –prints everything in the logs. But that prints huge data set. we are interested in just the body (i.e. api response)

val paj_request = exec(http("/platform/spi/auth/visitor/login")



.header(“X-AuthToken”, “${authToken}”)


def printapiresponse(args: String): Unit = {
exec { session =>
println(args + “>>>>>>api-response is” + session(“apiresponse”).as[String] + “<<<<<<”)

If my understanding is correct, printing session needs to be attached to the parent exec which stores bodyString. but that would require writing duplicate code for every api request.

right now in the above example nothing gets printed. Wondering if there is some way I can achieve above. could someone help here?