While trying to execute below script getting ERROR as i.g.h.a.HttpRequestAction - 'httpRequest-1' failed to execute: No attribute named 'testReqJson' is defined.
Need to set a session variable & pass it in body.
object PostTest extends BaseHttpRequest {
override val basicRequestExecutor = exec(_.set("testReqJson", createTestJsonPayload(100)))
.exec(hitApiAndVerify())
override protected def hitApi(): HttpRequestBuilder = {
http("testJson")
.post(testJson.APP_URL + "/test/json")
.body(StringBody("${testReqJson}")).asJson
.header("Content-Type", "application/json")
}
}
protected def hitApiAndVerify(): HttpRequestBuilder = super.hitApiAndVerify {
if (ConfigLoader.getPropertyOrElse("localProxy", "false").equalsIgnoreCase("true")) {
hitApi().proxy(Proxy("localhost", 8888))
} else {
hitApi()
}
}