Skip to content

400 BadRequestError on requests to local Elastic #2927

Closed
@AidanStrong

Description

@AidanStrong

This issue exists on version 9.0.0 of the elasticsearch-py package. It does not exist on version 8.16.0.

It is replicated on python 3.10.12 and python 3.12.3.

In the python shell:

>>> import elasticsearch
>>> es = elasticsearch.Elasticsearch("http://localhost:9200")
>>> es.indices.get_alias(index="*")

Get's the error:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/aidans/.local/lib/python3.10/site-packages/elasticsearch/_sync/client/utils.py", line 415, in wrapped
    return api(*args, **kwargs)
  File "/home/aidans/.local/lib/python3.10/site-packages/elasticsearch/_sync/client/indices.py", line 2278, in get_alias
    return self.perform_request(  # type: ignore[return-value]
  File "/home/aidans/.local/lib/python3.10/site-packages/elasticsearch/_sync/client/_base.py", line 422, in perform_request
    return self._client.perform_request(
  File "/home/aidans/.local/lib/python3.10/site-packages/elasticsearch/_sync/client/_base.py", line 271, in perform_request
    response = self._perform_request(
  File "/home/aidans/.local/lib/python3.10/site-packages/elasticsearch/_sync/client/_base.py", line 351, in _perform_request
    raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
elasticsearch.BadRequestError: BadRequestError(400, 'media_type_header_exception', 'Invalid media-type value on headers [Content-Type, Accept]')

My local elastic is configured in docker and reachable with curl. The docker image is: docker.elastic.co/elasticsearch/elasticsearch:8.14.1

The only environment variables I configure the instance with are:

discovery.type: single-node
xpack.security.enabled: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions