drew2
drew2

Reputation: 107

Karate DSL pulling out brackets when passed as json params

I'm trying to pass some json data as params in a feature. The request is failing because it looks like Karate is removing the brackets from the string I'm passing in. Once it make the request, I can see the brackets specifically after the "list" element is gone. If I take the encoded request that karate makes and manually add the brackets where they should be, it works fine.

We could try passing it in a couple other ways, but I'm trying to understand why it's changing what would work to something that won't.

This is what it looks like as the raw json being passed in.

"start": "1557943276102",
  "end": "1559152876102",
  "page": 1,
  "user": "0000000000000001",
  "list": [              <---- this bracket gets stripped
    {
      "field1": [
        "field2",
        "field3",
        "field4"
      ],
      "field5": "123456"
    }
  ],                     <---- this bracket gets stripped
  "authToken": "theauthtoken"
}

Then setting it to params like * params jsonData

My request fails, where if the brackets remained intact the request works.

Upvotes: 1

Views: 357

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

In the case of params an array means repeated values, which is common in real-life, see params.feature. If you really want a bracket, use a string value:

"list": '[{"field1":["field2","field3","field4"],"field5":"123456"}]'

Upvotes: 1

Related Questions