1

I want to do a Query API which returns me a 200 always, then check if the result has an array of elements and if it does not have then create the entity using POST API, if found, validate the entity details.

This is my code:

Given url url
And path 'offering'
When method GET
* def expected1 = response != null ? { expected: 'in if' } : { expected: 'in else' }

But this checks only for null value in response and does not check for null array in response

Dhamo
  • 1,171
  • 3
  • 19
  • 41

1 Answers1

2

This can be achieved by response.length:

Sample code:

eval if (response.length<=1) karate.call('offeringcreate.feature')
double-beep
  • 5,031
  • 17
  • 33
  • 41