简体   繁体   English

如何在空手道框架的post请求中传递多个参数?

[英]How to pass multiple parameters in post request in karate framework?

I have a JSON data file which has data like我有一个 JSON 数据文件,其中包含类似的数据

{
  "Status": "Pending",
  "role": "manager",
  "client": "android",
  "user": "test@abc.com",
  "eTyres":
  {
    "Wheels": {
      "title": "Alloy Wheel",
      "value": "Yes"
    }
 }
}

Firstly, I want to read this data and when Wheels.value == Yes then I want to hit an API else hit another API Also, I would like to know how i can pass multiple parameters in post request or from the file.首先,我想读取这些数据,当 Wheels.value == Yes 时,我想点击一个 API,否则点击另一个 API 另外,我想知道如何在 post 请求或文件中传递多个参数。

Post request data is as follows: post请求数据如下:

title:Alloy_wheel__Info
part:acCooling
partTitle:AC Cooling
partValue:No

Above data i'm passing through "form-data" in postman.以上数据我正在邮递员中通过“表单数据”。

Thanks in advance提前致谢

Your question is hard to understand and I will assume that you want to loop over some given JSON array and do some actions.你的问题很难理解,我假设你想遍历一些给定的 JSON 数组并执行一些操作。 Sounds like you are not "testing" and mis-using Karate !听起来你不是在“测试”和误用空手道!

To loop over a JSON array, use call .要遍历 JSON 数组,请使用call Refer the docs: https://github.com/intuit/karate#data-driven-features请参阅文档: https : //github.com/intuit/karate#data-driven-features

To do conditionals, read this part of the documentation: https://github.com/intuit/karate#conditional-logic要做条件,请阅读文档的这一部分: https : //github.com/intuit/karate#conditional-logic

To do "form-data" read this: https://github.com/intuit/karate#form-field要执行“表单数据”,请阅读: https : //github.com/intuit/karate#form-field

* def data = { "Status": "Pending", "role": "manager", "client": "android", "user": "test@abc.com", "eTyres": { "Wheels": { "title": "Alloy Wheel", "value": "Yes" } } }
* eval data.eTyres.Wheels.value == 'Yes' ? karate.call('api1.feature') : karate.call('api2.feature')

How to implement api1.feature and api2.feature is a homework for you.如何实现api1.featureapi2.feature是你的功课。 Keep in mind that in both you will still have access to the data variable.请记住,在两者中您仍然可以访问data变量。 And please read the docs and examples !请阅读文档和示例!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在空手道中动态传递发布请求参数以获取请求 - How to pass post request parameters dynamically to get request in Karate 如何在 Retrofit - Android 中将参数传递给 POST 请求 - How to pass parameters to POST request in Retrofit - Android 在 post http 请求中传递参数 - Pass parameters in post http request 如何使用Easy Post API传递多个参数 - How to pass multiple parameters using the Easy Post API 如何传递地图 <String, String> 参数或对象通过Retrofit POST请求? - How to pass Map<String, String> parameters or object to POST request via Retrofit? 如何使用okhttp在android中将web api(post request)URL参数作为requestbody传递 - how to pass web api(post request) url parameters as requestbody in android using okhttp Taxee API(http://www.taxee.io/)-JavaScript-如何:POST请求和传递参数 - Taxee API (http://www.taxee.io/) - JavaScript - How To: POST Request and Pass Parameters 如何参数化我在API请求中传递并通过空手道执行的参数? - How do i parameterize parameters i am passing in my API request & execute through Karate? 空手道框架保存来自 1 个请求的响应,然后在另一个请求中使用 - karate framework save response from 1 request and then use in another request 如何将REST请求的参数传递给Java方法? - How to pass parameters for REST request to Java method?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM