Headers for the Java REST Client

I understand that in elasticsearch 6 the content type header is mandatory. I get a nice exception when omitting it when connecting using the low level rest client.

{"error":"Content-Type header [text/plain; charset=ISO-8859-1] is not supported","status":406}

Is there a good reason not to include it by default? I know I can do this myself when creating the client using the default headers, but I would like to understand why this is not the default out of the box as almost all request will need it


as almost all request will need it

Sometimes if you want to use something like _bulk you are probably going to use another content-type than application/json. That's probably why.
Some people also want to provide yaml instead of json.

Note that the High Level client hides all that "complexity".

Ah good point, did not thing about those two usecases. Thanks.

I know about the high level client, I use it in projects already. I also like to use the low level client with a custom wrapper sometimes.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.