无法在空手道中指定Odata URL
如何为odata调用(如子字符串,startswith)编写uri.尝试了上述想法,但未对成功状态做出回应.也尝试在参数中追加,但uri似乎无法解决改正路径查询如:-》filter = substringof('m',Title)尝试:-》
How uri can be written for odata call like substring,startswith. Tried with above mentioned ideas but doesn't respond with success status .tried appending in param as well but uri doesn't seem to resolve to correct path Query like :-》 filter=substringof('m',Title) Trying like :-》
- 路径主机?$ filter = startswith(名称,"+",'?'"+")"
,但不能通过正确的uri解决.谢谢
but does not get resolved in correct uri . Thanks
要证明空手道做对了,请尝试以下操作:
To prove that Karate does the right thing, try this:
* url 'https://httpbin.org'
* path 'anything'
* def id = 123
* param $filter = "startswith(Name,'" + id + "')"
* request { foo: 'bar' }
* method post
空手道将发出此请求:
1 > POST https://httpbin.org/anything?%24filter=startswith%28Name%2C%27123%27%29
1 > Content-Type: application/json; charset=UTF-8
1 > Content-Length: 13
1 > Host: httpbin.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_231)
1 > Accept-Encoding: gzip,deflate
{"foo":"bar"}
您将从服务器获得实际响应:
And you will get an actual response from the server:
10:13:38.445 [main] DEBUG com.intuit.karate - response time in milliseconds: 1243
1 < 200
1 < Date: Tue, 13 Apr 2021 04:43:38 GMT
1 < Content-Type: application/json
1 < Content-Length: 589
1 < Connection: keep-alive
1 < Server: gunicorn/19.9.0
1 < Access-Control-Allow-Origin: *
1 < Access-Control-Allow-Credentials: true
{"args":{"$filter":"startswith(Name,'123')"},"headers": ""}
因此,请您根据自己的判断是否弄错引号,或者您的服务器无法处理编码的URL或路径/参数.
So I leave it up to you to figure if you got the wrapping of quotes wrong or if your server is not able to handle encoded URL or path / params.