Reputation: 139
When i send the Content-Type = 'application/x-www-form-urlencoded' as header it is changed to Content-Type: application/json; in Karate version 0.9.2 . In Karate version 0.7.0 it is sent as Content-Type = 'application/x-www-form-urlencoded' only .
Given url "https://foo.bar.buzz"
And header Content-Type = 'application/x-www-form-urlencoded'
And form field username = "check"
And form field password = "Password"
And request {}
And header Content-Type = 'application/json'
When method POST
Then status 200
Upvotes: 3
Views: 14618
Reputation: 58058
In the 3rd last line you have the header
set ?
And you should never use a request
body for a form submit.
Try the below, it works fine:
Given url 'https://postman-echo.com/post'
And form field foo = 'bar'
When method post
Result:
1 > POST https://postman-echo.com/post
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 7
1 > Content-Type: application/x-www-form-urlencoded; charset=UTF-8
1 > Host: postman-echo.com
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_112)
foo=bar
Upvotes: 5