Karate 如何在下一个请求中使用响应头中的位置?
我在做空手道测试 首先是一个职位,期待一个201和一个位置 第二,使用位置from response来执行get 有人知道我怎么用空手道吗 下面的代码是我的尝试,在许多其他代码之后Karate 如何在下一个请求中使用响应头中的位置?,karate,Karate,我在做空手道测试 首先是一个职位,期待一个201和一个位置 第二,使用位置from response来执行get 有人知道我怎么用空手道吗 下面的代码是我的尝试,在许多其他代码之后 Given path 'alpha/test' And request """ { "id": '#(uuid)', "content": "test", "isActive": true } """ When method post Then status 201 And def endp
Given path 'alpha/test'
And request
"""
{
"id": '#(uuid)',
"content": "test",
"isActive": true
}
"""
When method post
Then status 201
And def endpointLocation = responseHeaders['Location']
And print endpointLocation
Given url 'endpointLocation'
When method get
Then status 200
And match response ==
"""
{
"id": '#(uuid)'
}
"""
但我得到了:
18:30:12.819 [main] ERROR com.intuit.karate - org.apache.http.client.ClientProtocolException, http call failed after 252 milliseconds for URL: endpointLocation
18:30:12.820 [main] ERROR com.intuit.karate - http request failed:
org.apache.http.client.ClientProtocolException
testApi.feature:263 -
org.apache.http.client.ClientProtocolException
我不明白为什么
[编辑]
经过彼得的建议,我感谢你
打印返回:
08:59:33.610[主]信息com.intuit.karate-[打印][
“”]
现在我打电话来
给定url端点位置
我越来越
08:59:33.611[main]错误com.intuit.karate-http请求失败:java.net.URISyntaxException:索引0处方案名称中的非法字符:[“”]
fraudMgmtApi.feature:263-java.net.URISyntaxException:索引0处的方案名称中的非法字符:[“”]
我还尝试修剪第一个和最后一个角色,创建一个:
- def微调= """ 函数(myText){result=myText.substring(1,myText.length-1)} “”“
或myText.slice(1,-1)来自错误消息:
URL:endpointLocation的http调用在252毫秒后失败
很明显,您将url
设置错误。如果endpointLocation
变量设置正确,请首先尝试对其进行编码,然后进行此更改。您可以打印以进行检查
Given url endpointLocation
从错误消息中:URL:endpointLocation的http调用在252毫秒后失败
很明显,您将url
设置错误。如果endpointLocation
变量设置正确,请首先尝试对其进行编码,然后进行此更改。您可以打印以进行检查
Given url endpointLocation
谢谢@peter thomas,我已经更新了我的问题。(不知道如何更新贝娄您的答案:\@DavidGonçalves参考和感谢@peter thomas,我已经更新了我的问题。(不知道如何更新贝娄您的答案:\@DavidGonçalves参考和。)