Search code examples
karateintuit-partner-platform

How to disable encoding while passing a form field in karate


I am using the following code for 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

The username field is getting encoded which results in =>

grant_type=password&client_id=democlientid&client_secret=democlientsecret&password=randompass123&username=hello%40someone.com

The name is getting encoded as "hello%40someone.com" while being passed because of which the api call fails. How do I disable encoding so that "hello@someone.com" is passes.


Solution

  • Karate is doing the right thing, it is most likely you have mis-understood the issue - or you have a bug in your server: https://www.w3schools.com/Tags/ref_urlencode.asp

    Anyway if you insist on NOT encoding, you have to provide the request body manually. Use this example as a reference: https://github.com/intuit/karate/commit/58eeec344eb6b4194a7d5aa9bc5b2f0e934372ed