Hello Team,
I am trying to send one API request towards server and am able to get the response also from server. After that ill read the data using JsonPath.
But I have one condition where in server is not responding with 200 Ok and there by am getting exceptions as am reading the data using JsonPath.
Is there a way to read the response status other than 200 Ok and then discard the response? Also do we have any way to read the empty JsonPath in response.
This is exec1:
.exec(http("Test")
.post("MYURL")
.check(
status.saveAs("status"),
checkIf(session => session("status").as[Int] == 200) {
println(s"Response is 200 OK")
jsonPath("$..abc").findAll.saveAs("abc")
},
checkIf(session => session("status").as[Int] == 502) {
println("Response is 502 ")
substring("502 error").exists
}
)
In the next exec ill be calling another function based on the response from exec1
This is exec2
.exec(session =>
val abcValue = session("abc").as[String])
If(abcValue = "Test"){
Print("PASS")
}else {
Print("FAIL")}
)