3

Good day! In my negative test cases I have to PUT a request without Content-Type header in order to match desired 4xx status code. The problem is karate automatically sets an appropriate Content-Type. E.g. when I pass {} as request it sets application/json; charset=UTF-8 when I pass '' as request it sets text/plain; charset=UTF-8

The question is how can I send a PUT request without a Content-Type header?

2 Answers2

4

You can pass Content-Type by using the below line:

And header Content-Type = 'application/json; charset=utf-8'

Sudheer Singh
  • 555
  • 5
  • 10
3

Just set * configure charset = null:

Here is the documentation: https://github.com/intuit/karate#configure

For a detailed example, see: content-type.feature

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 1
    Sorry, but the question is how can I send a PUT/POST request without a Content-Type header, not without charset. – firstName lastName Dec 19 '18 at 12:24
  • @firstNamelastName - sorry this is not supported, the best you can do is set the `Content-Type` to an empty string. you are the first EVER to have asked for this - so if this is very important for you - please contribute a patch, this is an open-source project after all - else write this particular test in pure java. – Peter Thomas Dec 20 '18 at 12:34