1

I have recently learnt about Karate and it's awesome experience working on this. I'm stuck at one problem and looked out for a solution from various websites but it didn't help

Scenario: Given url "https://test.payu.in/_payment" And form field surl = '/payu/web-response/17703721?appVersion=null&clientId=web-client/1.0' When method POST Then status 302

When we hit the above request the form field value is getting encoded as 'surl=%2Fpayu%2Fweb-response%2F17703721%3FappVersion%3Dnull%26clientId%3Dweb-client%2F1.0' due to this request is failing

If you can provide me the solution it would be really helpfull Solutions tried : java.net.URLDecoder.decode('/payu/web-response/17703721?appVersion=null&clientId=web-client/1.0', 'UTF-8')

But no luck

Uday Kumar
  • 59
  • 1

1 Answers1

0

Karate is doing the right thing. You can see for yourself using this 3-line Karate test:

* url 'https://httpbin.org/anything'
* form field foo = 'one/two?three=four'
* method post

You can see that the "raw" request is:

1 > POST https://httpbin.org/anything
1 > Content-Type: application/x-www-form-urlencoded
1 > Content-Length: 28
1 > Host: httpbin.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.11)
1 > Accept-Encoding: gzip,deflate
foo=one%2Ftwo%3Fthree%3Dfour

But in the response, you can see the server handled it correctly:

1 < 200
1 < Date: Wed, 06 Oct 2021 12:06:10 GMT
1 < Content-Type: application/json
1 < Content-Length: 513
1 < Connection: keep-alive
1 < Server: gunicorn/19.9.0
1 < Access-Control-Allow-Origin: *
1 < Access-Control-Allow-Credentials: true
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "foo": "one/two?three=four"
  }, 
  "headers": {
    "Accept-Encoding": "gzip,deflate", 
    "Content-Length": "28", 
    "Content-Type": "application/x-www-form-urlencoded", 
    "Host": "httpbin.org", 
    "User-Agent": "Apache-HttpClient/4.5.13 (Java/11.0.11)", 
    "X-Amzn-Trace-Id": "Root=1-615d9132-260dcbf96f57a6992b6273dc"
  }, 
  "json": null, 
  "method": "POST", 
  "origin": "122.179.54.225", 
  "url": "https://httpbin.org/anything"
}

See the JSON field called form in the response.

I think you should do some research, or talk to your "server" team. Who knows, maybe Karate has found a bug for you.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248