문제

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