vendredi 24 août 2018

How to pass response body field to other request's body (Gatling)

I have two end point.

-/authenticate

-/authenticate/verification

/authenticate return guid field on response body. and /authenticate/verification requires that field on request body.

I have tried to get guid like this :

jsonPath("$..guid").saveAs("verificationGuid")

and pass it to other body :

.body(StringBody(s"{\"guid\":${verificationGuid}, \"code\":\"123456\"}"))

this is the code block:

 def login = {
    exec(http("Authenticate")
      .post("/authenticate")
      .body(StringBody(userString))
      .headers(headerLogin)
      .check(status is 200)
      .check(jsonPath("$..guid").saveAs("verificationGuid"))
    )
    .exec(http( "Authenticate verify")
    .post("/authenticate/verify")
    .headers(headerLogin)
    .body(StringBody(s"{\"guid\":${verificationGuid}, \"code\":\"123456\"}"))
    .check(status is 200)
    )
  }

But it doesnt work, how can I do this?

Aucun commentaire:

Enregistrer un commentaire