空手道 DSL 框架是否能够将 POST 请求作为 url 编码格式传递?
Does Karate DSL Framework have the capability to pass a POST Request as a url encoded format?
我项目中的某些 API 只能使用编码格式通过 OAuth 2.0 访问。我可以使用 POSTMAN 手动提交 POST,因为它具有 x-www-form-urlencoded 功能来发送请求(附图片)。作为解决方法,我创建了一个 java 函数来将我的 json 正文转换为编码的 URI 并作为变量传递。但是,当 运行 时,我得到 "http call failed for URL"。我想知道空手道是否有自己的库来将 json 转换为编码 URI。
场景:Json 到 POST 主体上的编码 URI
* def JavaDemo = Java.type('com.ge.health.gam.service.servicerequest.testsuite.CustomJavaClass')
* def encodedURI = JavaDemo.jsonToURI()
* print encodedURI
Given url 'http://location.ver02.geicenter.com/uaa/oauth/token'
And request encodedURI
When method post
Then status 200
com.intuit.karate.exception.KarateException:http 调用在 URL 的 263 毫秒后失败:http://location.ver02.geicenter.com/uaa/oauth/token
是的。请参考form field
. There is also an OAuth 2 example in the demos的文档,寻找它。
另见:
根据 Peter Thomas 的建议,我发现以下内容可以通过 Oath 2.0 提交请求。就我而言,我还必须安装所需的证书才能收到有效的响应。您还必须考虑到这一点。
Given path 'uaa', 'oauth', 'token'
And form field key = 'value'
And form field key = 'value'
And form field key = 'value'
And form field key = 'value'
When method post
Then status 200
我项目中的某些 API 只能使用编码格式通过 OAuth 2.0 访问。我可以使用 POSTMAN 手动提交 POST,因为它具有 x-www-form-urlencoded 功能来发送请求(附图片)。作为解决方法,我创建了一个 java 函数来将我的 json 正文转换为编码的 URI 并作为变量传递。但是,当 运行 时,我得到 "http call failed for URL"。我想知道空手道是否有自己的库来将 json 转换为编码 URI。
场景:Json 到 POST 主体上的编码 URI
* def JavaDemo = Java.type('com.ge.health.gam.service.servicerequest.testsuite.CustomJavaClass')
* def encodedURI = JavaDemo.jsonToURI()
* print encodedURI
Given url 'http://location.ver02.geicenter.com/uaa/oauth/token'
And request encodedURI
When method post
Then status 200
com.intuit.karate.exception.KarateException:http 调用在 URL 的 263 毫秒后失败:http://location.ver02.geicenter.com/uaa/oauth/token
是的。请参考form field
. There is also an OAuth 2 example in the demos的文档,寻找它。
另见:
根据 Peter Thomas 的建议,我发现以下内容可以通过 Oath 2.0 提交请求。就我而言,我还必须安装所需的证书才能收到有效的响应。您还必须考虑到这一点。
Given path 'uaa', 'oauth', 'token'
And form field key = 'value'
And form field key = 'value'
And form field key = 'value'
And form field key = 'value'
When method post
Then status 200