如何在空手道中传递表单字段时禁用编码
How to disable encoding while passing a form field in karate
我正在使用以下代码进行 oauth。
Feature: Verify Generate Token Email api is up and running
Scenario: Verify Generate Token Email api
Given url 'demourl'
And header Content-Type = 'application/x-www-form-urlencoded; charset=utf-8'
And form field grant_type = 'password'
And form field client_id = 'democlientid'
And form field client_secret = 'democlientsecret'
And form field password = 'randompass123'
And form field username = 'hello@someone.com'
When method post
Then status 200
* print response
用户名字段正在编码,导致 =>
grant_type=password&client_id=democlientid&client_secret=democlientsecret&password=randompass123&username=hello%40someone.com
名称在传递时被编码为 "hello%40someone.com",因此 api 调用失败。如何禁用编码以便 "hello@someone.com" 通过。
空手道做得对,很可能是您误解了问题 - 或者您的服务器存在错误:https://www.w3schools.com/Tags/ref_urlencode.asp
无论如何,如果您坚持不编码,则必须手动提供请求正文。使用此示例作为参考:https://github.com/intuit/karate/commit/58eeec344eb6b4194a7d5aa9bc5b2f0e934372ed
我正在使用以下代码进行 oauth。
Feature: Verify Generate Token Email api is up and running
Scenario: Verify Generate Token Email api
Given url 'demourl'
And header Content-Type = 'application/x-www-form-urlencoded; charset=utf-8'
And form field grant_type = 'password'
And form field client_id = 'democlientid'
And form field client_secret = 'democlientsecret'
And form field password = 'randompass123'
And form field username = 'hello@someone.com'
When method post
Then status 200
* print response
用户名字段正在编码,导致 =>
grant_type=password&client_id=democlientid&client_secret=democlientsecret&password=randompass123&username=hello%40someone.com
名称在传递时被编码为 "hello%40someone.com",因此 api 调用失败。如何禁用编码以便 "hello@someone.com" 通过。
空手道做得对,很可能是您误解了问题 - 或者您的服务器存在错误:https://www.w3schools.com/Tags/ref_urlencode.asp
无论如何,如果您坚持不编码,则必须手动提供请求正文。使用此示例作为参考:https://github.com/intuit/karate/commit/58eeec344eb6b4194a7d5aa9bc5b2f0e934372ed