not able to fetch a value from response array

Viewed 26

I have a response body as below.

{ "issue": [{ "reason": "SELECTED ITEMS WERE ISSUED", "isSuccess": true }] }

I want to validate : reason = "SELECTED ITEMS WERE ISSUED" and isSuccess = true.

I tried this :

  • assert response.issue[0].reason == 'SELECTED ITEMS WERE ISSUED'
  • match response.issue[0].isSuccess == true

but always get this error javax.script.ScriptException: TypeError: Cannot get property "0" of null in

1 Answers

Works perfectly for me, paste these 3 lines into any test and see for yourself:

* def response = { "issue": [{ "reason": "SELECTED ITEMS WERE ISSUED", "isSuccess": true }] }
* match response.issue[0].reason == 'SELECTED ITEMS WERE ISSUED'
* match response.issue[0].isSuccess == true
Related