print to console for debugging only when jsonPath exists (does not exist)

given my .exec

`

.exec(http(“LOOKUP”)

.post("/nice/nice_ajax?ajax_id=LOOKUP&ajax_applid=UI5_INVENTORY_LOOKUP&field_id=00003&ajax_value=${timestamp}")

.headers(headers)

.check(status.is(200))

.check(jsonPath("$.modeltabResultsData[0].MATNR").exists))

`

if the jsonPath .exists fails (it says found nothing) sometimes, I want to print some in-session parameter.

Can I surround an .exec with an if loop having this condition in some way, and say if this condition is true then:

`

.exec(session => {

println((session(“inSessionParameter”).as[String]))

session})

`

where would I put the loop?

Thanks!

Hi,

You can use ether

*println*((session(**"inSessionParameter"**).asOption[String]))

(it will not fail in case if there is no such value in session)

OR

.doIf(session => session(**"inSessionParameter"**).isDefined) {

exec(session => {

*println*((session(**"inSessionParameter"**).as[String]))

``session})}

Regards,
Alex.