空手道API如何捕获响应值以作为请求传递给另一个API

时间:2019-06-09 20:56:57

标签: karate

捕获一个API调用的响应字段,并将其作为输入参数发送给另一个API调用

Given url petStoreUrl
And request {  "id": 1, "category": {"id": 0 ,"name": "golden doodle" },"name": "scooby", "photoUrls": ["string"], "tags": [{ "id": 0,"name": "scooby"}],"status": "available" }
When method post


{ "id": 9199424981609294382, "category": { "id": 0, "name": "golden doodle" }, "name": "scooby1", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "scooby" } ], "status": "available" }

我想将上述调用的响应ID "id": 9199424981609294382作为此获取请求的输入参数发送 路径/ ID

1 个答案:

答案 0 :(得分:0)

您确实需要阅读文档。 "hello world" example本身向您展示了如何执行此操作。

Given path response.id
When method get

请仔细阅读本节:https://github.com/intuit/karate#url