mercredi 22 avril 2020

Extract and comparing data from json array not working in karate

I am trying to search a certain value in a JSON array using the value stored in a variable and then comparing somehow this is not working for me. Can you please help. BillerId1 is always returning a blank value

Given url buyerApi
Given url paymentHub
Then path '/BPAY/v' + version + '/billers'
And header Authorization = 'Bearer ' + token
When method get
Then  status 200
* def id = response[0].savedBillerId
Then url paymentHub
Then path '/BPAY/v' + version + '/billers/' +id
And header Authorization = 'Bearer ' + token
And request {billerCode:<billerCode>, billerCRN:'<billerCRN>'}
When method put
Then status 200
Then url paymentHub
Then path '/BPAY/v' + version + '/billers'
And header Authorization = 'Bearer ' + token
When method get
Then  status 200
* print id
* def billId1 = get[0] response[?(@.savedBillerId==**'#id'**)].savedBillerId
* print billId1
And match billId1 == id
Examples:
         | billerCode | billerCRN    |
         | 65284      | 65112345675  |

Array looks like this

 [
 {
"savedBillerId": "ebfa2b9f-f49c-4b0c-c6ee-08d7e671944a",
"billerId": "26c67edb-b3dc-44ea-aa74-08d7d6890798",
"billerName": "test case 21c",
"billerCode": 65284,
"crn": "65112345675"
},
{
"savedBillerId": "500dfde7-e31c-408d-c6ef-08d7e671944a",
"billerId": "26c67edb-b3dc-44ea-aa74-08d7d6890798",
"billerName": "test case 21c",
"billerCode": 65284,
"crn": "65112345672"
}

]

@ptrthomas

Aucun commentaire:

Enregistrer un commentaire