Getting error when try to fetch value from API response in Karate

Viewed 39

I am trying to fetch a value from my API response. But it is throwing error:

My API response:

{
"metadata": {
    "count": 68,
    "query_time": "241.674ms"
},
"aggResultValue": [
    {
        "product": "ABC",
        "min(price)": 64
    },
    {
        "product": "DEF",
        "min(price)": 30
    }
  ]

}

When I use,

$.aggResultValue[*].min(price)

it returns an error:

 pricemax.feature:42 - Aggregation function attempted to calculate value using empty array

I am a little confused why I am getting this error, as I am just trying to get the value, not calculating anything.

Any alternative validation approach would also help me here.

1 Answers

Do this instead:

$.aggResultValue[*]['min(price)']
Related