Gatling/Scala: Returns error in Jsonpath - Extraction Crashed: end of input expected

Asked

Viewed 16 times

0

Hello! I’m new to Gatling/Scala and the scenario is as follows: I need to make a request in an API and use the Response data in a new call, which is the load itself. However, Gatling returns the error:

> jsonPath($[*]dadosContrato[*].codContrato).findAll.exists extraction
> crashed: end of input expected

And the code is like this:

val scn = scenario("Cenário")
        .exec(_.set("codContrato", Seq.empty[String]))
        .exec(http("GET_ObtemCodContrato")
        .get("/lista")
        .queryParam("DataInicio", "2020-12-20T16:46:23.895Z")
        .queryParam("DataFim", "2020-12-21T16:46:23.895Z")
        .header("Content-Type", "application/json")
        .check(jsonPath("$[*]dadosContrato[*].codContrato").findAll.saveAs("codContrato")))

The answer to this GET is:

{
  "dadosContrato": [
    {
      "codContrato": "A1A1A1A1A1A1",
      "outroId": "11AA22BB"
    },
    {
      "codContrato": "A2A2A2A2A2A2",
      "outroId": "33BB44CC"
    },
    {
      "codContrato": "A3A3A3A3A3A3",
      "outroId": "55CC66DD"
    }
]

I tried several forms of jsonPath notation, also testing in jsonpath.com but no way that works there, it works well.

Does anyone have any idea how to make it work?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.