Frage

Say I need to write a gatling Load test script that needs to call two APIs A1 and A2. It first needs to call A1 which will return a JSON payload, it needs to extract a field in the JSON payload and use that field value in calling the second API. Can anyone let me know how can I do that? This script is for Load Testing our servers restful APIs that are over HTTP.

War es hilfreich?

Lösung

You can do that using jsonpath checks and by saving the result to the session.

It is documented here in the http check and session pages.

This will look like this:

exec(
  http("api 1")
  .get("api1url")
  .check(jsonPath("/my/json/field").saveAs("myValue"))
)
.exec(
  http("api 2")
    .get("api2url/${myValue}")
)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top