[英]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}} "data":{"books":{"isbn":"97895113132","Bookid":10196333}}
sometimes i will get Bookid as null.有时我会将 Bookid 设为 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.我的问题是,只有当它不为空时,我才必须使用此 bookid,然后将其作为查询参数传递给下一个 api。
please help to find the solution for this using karate framework请帮助使用空手道框架找到解决方案
Easy, if you use the params
keyword, any value of null
is not sent as a param.很简单,如果您使用
params
关键字,则任何null
都不会作为参数发送。 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如果您正在寻找条件逻辑 - 请阅读: https : //github.com/intuit/karate#conditional-logic
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.