You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating a RestClientTransport with a LLRC RequestOptions leads every request to fail with co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/indices.create] failed: [media_type_header_exception] Invalid media-type value on headers [Accept, Content-Type]
How to reproduce
transport = newRestClientTransport(restClient, mapper)
.withRequestOptions(newRestClientOptions.Builder(
RequestOptions.DEFAULT.toBuilder()
// add other options as needed
).build());
client = newElasticsearchClient(transport);
Explanation
The Java API client sends a Content-Type: "application/vnd.elasticsearch+json;compatible-with=8" header with every request, and the ES server expects to see the same value for the Accept header. Setting custom RequestOptions override the Java API client built-in RequestOptions that sets this header.
Workaround
Manually set the Accept header:
transport = newRestClientTransport(restClient, mapper)
.withRequestOptions(newRestClientOptions.Builder(
RequestOptions.DEFAULT.toBuilder()
.addHeader("Accept", "application/vnd.elasticsearch+json;compatible-with=8")
// add other options as needed
).build());
client = newElasticsearchClient(transport);
The text was updated successfully, but these errors were encountered:
Creating a
RestClientTransport
with a LLRCRequestOptions
leads every request to fail withco.elastic.clients.elasticsearch._types.ElasticsearchException: [es/indices.create] failed: [media_type_header_exception] Invalid media-type value on headers [Accept, Content-Type]
How to reproduce
Explanation
The Java API client sends a
Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
header with every request, and the ES server expects to see the same value for theAccept
header. Setting customRequestOptions
override the Java API client built-inRequestOptions
that sets this header.Workaround
Manually set the
Accept
header:The text was updated successfully, but these errors were encountered: