Skip to content

[Elastic.Clients.Elasticsearch 9.0.7] Invalid media-type error when indexing or querying with Elasticsearch 8.13.x #8627

@berkay-huz

Description

@berkay-huz

[Elastic.Clients.Elasticsearch 9.0.7] Invalid media-type value on headers [Content-Type, Accept] when using ES 8.13.x

Elastic.Clients.Elasticsearch version: 9.0.7

Elasticsearch version: 8.13.4 (Docker)

.NET runtime version: .NET 9 — also tested with .NET 8

Operating system version: Windows 11 + Linux (Docker container)

Description of the problem including expected versus actual behavior:

When using Elastic.Clients.Elasticsearch v9.0.7 to interact with an Elasticsearch 8.13.4 cluster, all operations like IndexAsync, SearchAsync, and PingAsync fail with the following error:

Invalid media-type value on headers [Content-Type, Accept]

Expected behavior: the client should send the appropriate headers (Content-Type: application/vnd.elasticsearch+json;compatible-with=8) automatically or provide a way to configure them.

Steps to reproduce:

  1. Use Elastic.Clients.Elasticsearch v9.0.7
  2. Connect to an Elasticsearch 8.13.4 cluster
  3. Try to run IndexAsync or SearchAsync
  4. Observe the media-type header error

Expected behavior

All operations should succeed if Elasticsearch is reachable. The client should default to setting proper Accept and Content-Type headers or expose a configuration API (like .DefaultMimeType(...)).

Provide ConnectionSettings:

var settings = new ElasticsearchClientSettings(new Uri("http://elasticsearch:9200"))
    .DefaultIndex("logservice-logs")
    .DefaultFieldNameInferrer(p => p.ToLowerInvariant())
    .DisableDirectStreaming()
    .EnableDebugMode()
    .PrettyJson();

Provide DebugInformation:

Elastic write failed: Log yazılamadı., Invalid media-type value on headers [Content-Type, Accept]
Elastic query failed: Invalid media-type value on headers [Content-Type, Accept]
HealthCheck failed: elastic_ping_check → Unhealthy (Invalid media-type header)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions