asif anwar
asif anwar

Reputation: 77

Karate : passing value as query parameter from one response if that value is not null

i have one response as below

"data":{"books":{"isbn":"97895113132","Bookid":10196333}}

sometimes i will get Bookid as null.

my question is, i have to take this bookid only if it is not null, and then pass to next api as query parameter.

please help to find the solution for this using karate framework

Upvotes: 1

Views: 585

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

Easy, if you use the params keyword, any value of null is not sent as a param. You can try this:

* def temp = null

Given url 'http://httpbin.org'
And path 'get'
And params { foo: '#(temp)' }
When method get
Then status 200

If you are looking for conditional-logic - please read: https://github.com/intuit/karate#conditional-logic

Upvotes: 1

Related Questions