1

I have written an api test using karate framework. While doing a post call it's converting the value of email field from TEST@ABC.COM to TEST%40ABC.COM.

Here are few lines from log

1 > Content-Type: application/x-www-form-urlencoded; charset=UTF-8
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_221)
email=TEST%40ABC.COM&checkDigit=&brandName=
Mudit Shukla
  • 814
  • 2
  • 6
  • 16

1 Answers1

1

This is correct as per the HTTP spec: https://stackoverflow.com/a/53638335/143475

You can see for yourself, try this:

* url 'http://httpbin.org'
* path 'anything'
* form field username = 'john@smith.com'
* form field password = 'secret'
* method post

Result:

1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 41
1 > Content-Type: application/x-www-form-urlencoded; charset=UTF-8
1 > Host: httpbin.org
1 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_231)
username=john%40smith.com&password=secret

But when you see the response, you can see the server handled it correctly, look at the form in the JSON:

1 < 200
1 < Access-Control-Allow-Credentials: true
1 < Access-Control-Allow-Origin: *
1 < Connection: keep-alive
1 < Content-Length: 555
1 < Content-Type: application/json
1 < Date: Tue, 07 Apr 2020 13:11:58 GMT
1 < Server: gunicorn/19.9.0
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "password": "secret", 
    "username": "john@smith.com"
  }, 
  "headers": {
    "Accept-Encoding": "gzip,deflate", 
    "Content-Length": "41", 
    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", 
    "Host": "httpbin.org", 
    "User-Agent": "Apache-HttpClient/4.5.12 (Java/1.8.0_231)", 
    "X-Amzn-Trace-Id": "Root=1-5e8c7c1e-affe121cae9f4b20399b0884"
  }, 
  "json": null, 
  "method": "POST", 
  "origin": "49.206.10.30", 
  "url": "http://httpbin.org/anything"
}
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248