I’m trying to print the response that I receive but not able to. Tried the below
.check(bodyString.saveAs("BODY))) .exec(session => { println(session("BODY").as[String]) }
However,
.check(bodyBytes.exists)
passes so, that means that body exisits right?
How can I print the body of the response.
couple of issues
#1 return object session is missing
#2 typo in saveAs double quotes isn’t closed.
#3 extra close brackets in the check, may be?
.check(bodyString.saveAs(“BODY”))
.exec(session => {
println(session(“BODY”).as[String])
session
}
Yeah sorry those were my typos’ but even accurate syntax doesn’t work
Try to print outside the .exec() and create a new .exec() for printing. Updated code-
.exec(http(“xxx”)
.check(bodyString.saveAs(“BODY”)))
.exec ( session => {
println(session(“BODY”).as[String])
session
})
Maria
5
I am using something like this (you can get rid of doIf block and log in info level
.exec(
http("Submit order")
.post("/v1/commercial-schemes/" + commercialScheme + "/sales/orders/" + "${uuidkey}" + "/submit")
.header("Authorization", "Bearer " + "${token}")
.body(ElFileBody("SubmitOrderRequest.json"))
.check(
status.in(202),
jsonPath("$.value.@type").is("CoreKit.Empty"),
bodyString.saveAs("submitbody")
)
)
.doIf(session => session.isFailed)(
exec(session => {
logger.error("uuidkey: " + session("uuidkey").as[String])
logger.error("sa_id: " + session("sa_id").as[String])
logger.error("conf_id: " + session("conf_id").as[String])
logger.error("body of add order: " + session("addbody").as[String])
logger.error("body of submit: " + session("submitbody").as[String])
session
}
)
logger init: