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.

有帮助吗?

解决方案

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}")
)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top