[英]How to pass post request parameters dynamically to get request in Karate
How do I pass a value of one API attribute to another API while automating in Karate ?在Karate 中自动化时如何将一个 API 属性的值传递给另一个 API? I have a POST request which when submitted will generate an id in the response, and I pass that id dynamically to the upcoming GET request.
我有一个 POST 请求,提交时将在响应中生成一个 id,我将该 id 动态传递给即将到来的 GET 请求。 I have already tried writing an Java method to read and write but it doesn't work.
我已经尝试编写一个 Java 方法来读写,但它不起作用。
Please forget about Java for a moment, Karate is very different !请暂时忘记Java,空手道非常不同!
For you I suggest you do this.对于你,我建议你这样做。 Use the ZIP Release: https://github.com/intuit/karate/wiki/ZIP-Release
使用 ZIP 版本: https : //github.com/intuit/karate/wiki/ZIP-Release
There is a ready-made test users.feature
.有一个现成的测试
users.feature
。 See how line 12 extracts the first array element from the response and then we need to use the id
key out of that element (which is a JSON object).看看第 12 行如何从响应中提取第一个数组元素,然后我们需要使用该元素(这是一个 JSON 对象)中的
id
键。
And then on line 14, it is used to make the next request.然后在第 14 行,它用于发出下一个请求。
Please spend some time reading the documentation , it is worth it !请花一些时间阅读文档,这是值得的!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.