2

We have to call two APIs only once in whole project which is a pre-requisite for all other features to run. All features are using values set in userId and unitId.

The first feature call is working fine but I am not sure how to add if condition on status code as only when the status code of first feature@test1 is 200 only then we want to call the second one else not.

The below code displayed the value as

User Id is -------------378

But is not going in the if condition although this API returned response code as 200.

 var result = karate.callSingle('classpath:util/users.feature@test1',config);
  config.userId = result.response.value[0].id;
  karate.log("User Id is -------------" + config.userId)
  if( result.status == 200 ) 
  {
    var result1 = karate.callSingle('classpath:util/users.feature@test2',config);
    config.unitId = result1.response.value[0].id;
    karate.log("Unit Id is -------------" + config.unitId)
  }

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Maddy
  • 674
  • 1
  • 7
  • 26

1 Answers1

1

It should be result.responseStatus.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248