I am trying to copy data from the json response into the Session so I can use them for subsequent calls.
The best I got is the below code, but the “${response.get(“skey”)}” does not work and I am out of ideas how I could do it.
Am I on the wrong path here? Thanks!
def parseLoginResponse(body: String) : Map[String,Any] = {
val json:Option[Any] = JSON.parseFull(body)
val response:Map[String,Any] = json.get.asInstanceOf[Map[String, Any]]
val user_id:Double = response.get(“user_id”).get.asInstanceOf[Double]
val skey:String = response.get(“skey”).get.asInstanceOf[String]
val success:Boolean = response.get(“success”).get.asInstanceOf[Boolean]
Map(“user_id” → user_id.toInt, “skey” → skey, “success” → success)
}
val scn = scenario(“scenario_1”)
.feed(user_info_generator)
.exec(
http(“step_1”)
.post("/login/")
.param(“uid”, “${username}”)
.headers(headers_3)
.check(status.is(200),
bodyString.transform( body => {
parseLoginResponse(body)
}
).saveAs(“response”))
)
.exec(
http(“step_2”)
.post("/do/something/")
.param(“user_id”, “${response.get(“user_id”)}”)
.param(“skey”, “${response.get(“skey”)}”)
.headers(headers_3)
.check(status.is(200))
)