如何在空手道中传递表单字段时禁用编码

时间:2018-06-15 07:29:42

标签: karate intuit

我正在使用以下代码来表示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"是通行证。

1 个答案:

答案 0 :(得分:1)

空手道正在做正确的事情,很可能你误解了这个问题 - 或者你的服务器中有错误:https://www.w3schools.com/Tags/ref_urlencode.asp

无论如何,如果你坚持不编码,你必须手动提供请求体。使用此示例作为参考:https://github.com/intuit/karate/commit/58eeec344eb6b4194a7d5aa9bc5b2f0e934372ed