Passing Result from one execution to another within the same scenario

Hi,

I like to know if there is a possbility to pass parameter from previous call to the next call and proceed.
I.e. I want to pass the jobId i get from the response JSON from first part to the next execution to check for the status.

When i run it, i get empty JobId.

var jobId = “”

val jobIdText = “jobId”:"";
val formatResponse : PartialFunction[io.gatling.http.response.Response,io.gatling.http.response.Response] = {
case response if response.isReceived => new io.gatling.http.response.ResponseWrapper(response) {
override val body = {
if(response.body.string.indexOf(jobIdText) != -1){
var tomcatString = response.body.string.substring(response.body.string.indexOf(jobIdText))
jobId = tomcatString.substring(0+jobIdText.length,response.body.string.indexOf("",")-6)
println("JOBID : "+jobId)
}
io.gatling.http.response.StringResponseBody(response.body.string, java.nio.charset.Charset.forName(“UTF-8”))
}
}
}

var scn1: io.gatling.core.structure.ScenarioBuilder =
initScenario(“StandaloneWorkflow_1”).feed(recordsInformation)
.exec(initJsonAcceptPOST(
initJsonContentTypePOST(
initMyComputePOST(
http(“StandaloneWorkflow_installStandalone”)
.post("/users/${id}/patternJobs/standalone")
.body(StringBody("""{${InstallJSON}}""")).asJSON
.transformResponse{
formatResponse
}
)
)
)
)
.exitBlockOnFail {
tryMax(10) {
pause(30)
.exec(initGET(
http(“CHECK_STATUS”)
.get("/users/${id}/patternJobs/standalone/"+jobId).check(status.is(200),
regex(“SUCCESS”)
)
)
)
}
}
.exec(initJsonAcceptPOST(
initJsonContentTypePOST(
initMyComputePOST(
http(“StandaloneWorkflow_installStandalone”)
.post("/users/${id}/patternJobs/standalone")
.body(StringBody("""{${UninstallJSON}}""")).asJSON
)
)
)
)//end of exec

Found a solution.

.check(jsonPath("$.jobId").exists.saveAs(“installJobId”))

:slight_smile: