Hi,
I wrote a very basic load test in Gatling 2.0 RC2 which hits a couple different REST endpoints (see below). One of them returns JSON. I would like to extract data from the response and use it in a subsequent REST call. This seems to be possible with a combination of jsonPath/asJSON/check/saveAs. But I couldn’t find a working example yet that uses all of those in combination.
POSTing to /merchant returns something like
{
“Id”: 5039424849051648,
“Description”: “a”,
“Modulo”: 1
}
I want to extract the “Id” field from the response and use it in a GET call to /merchant?m=${id}.
val scn = scenario(“Gatling test”)
.repeat(10) {
exec(http(“create merchant”).put("/merchant").body(StringBody("{“Description”:“test”,“Modulo”:5}")).asJSON.check(bodyString.transform(string => string).saveAs(“merchantId”)))
.exec(http(“get merchant”).get("/merchant?m=${merchantId}"))
// …
}
// …
My current expression puts the entire response of POST /merchant into $merchantId. How can I change the exec() call to extract the Id field?
Thanks,
Ingo