简体   繁体   English

空手道:如果该值不为空,则从一个响应中将值作为查询参数传递

[英]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.

相关问题 空手道:将变量从一个特征文件传递到另一个作为查询参数 - Karate : Passing variable from one feature file to another as a query parameter 在空手道中将变量从一个特征文件传递到另一个特征文件作为请求 URL(不是查询参数)的一部分 - Passing a variable from one feature file into another as a part of request URL(not query parameter) in Karate 空手道:将特定值分配给响应中的变量 - Karate: Assign specific value to a variable from a response 空手道 API 测试 - 检查响应值是否为空的方法 - Karate API Testing - Way to check that there is no null in response value 空手道:无法将从一个 api 响应中提取的 header 值传递到另一个 Z8A5DA52ED126447D 的请求 header 中 - Karate: Not able to pass header value extracted from one api response into the request header of another api 如何从一个特征文件表中读取数据并传递值以在空手道的 *.json 文件中设置 json 参数? - How to read data from one feature file table and pass the value to set json parameter in a *.json file in karate? 基于空手道响应值的条件 - Condition based on response value in karate 如何检查空手道节点是否包含来自json响应的期望值 - How to check in karate if a node contains the expected value from the json response 如何从空手道数组格式的json响应中获取值 - How to fetch value from a json response which is in array format in karate 空手道-从另一个特征文件中的响应中获取字段的值 - Karate- get value of a field from response in another feature file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM