简体   繁体   中英

Get only the response body in gatling

I need to parse an id from the response body and send it in the next request body in gatling for session based users. If anyone has an idea about that, please share it.

I have used the .check(regex()) and .saveAs method, but that saves the data in session, for which I need to do a complex parsing which I dont want.

Save it in the session using:

.check(jsonPath("$.id").saveAs("id"))

To send it in the next request, extract it first using

val id = session.get("id").as[String]

Alternatively, if you want to use it in the next request in the chain:

def get(token: String, org: String): ChainBuilder = {
    val url = MY_SERVICE_URI + "/${id}"
    exec(http("Get something")
      .get(url)
      .header(HttpHeaders.AUTHORIZATION, token)
      //etc'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM