ApiError(406, 'Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported',

Hii..

ApiError(406, 'Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported', 'Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported')

When I updated my python from 3.6 to 3.10 I got this Error. am using Elasticsearch 7.2.0 and the python module is pip version of elasticsearch 6.0.0

elasticsearch 6.0.0 is EOL and no longer supported. Please upgrade ASAP.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

Now, am installed 7.0.0 still facing the same error

Hi @Anand_Konagala ,

Could you please share the following information:
1 - Elasticsearch server version
2 - Elasticsearch client library version (Python module)
3 - The code snippet that is generating the error (without including credential information, please)

Thank you.

Hi @Alex_Salgado-Elastic

Elasticsearch Version -- 7.2.0
Elasticsearch library version is -- 7.0.0
Python Version 3.10.9
When I Perform any query individually It works well. But, When I Working on Flask API at the line of query It generates the error like that

hits = esconnection.search(index=index_name, _source=projection,
body={"size": size, "from": skip, "track_total_hits": True, "query": search_query, "aggs": aggregation})

Connection -- esconnection = Elasticsearch(hosts="localhost", port=9200, http_auth=("username", "password"), timeout=60)

Thank you.

And what's the Flask version?

Flask -- 2.3.2
Flask-API -- 3.0.post1

Hi @Anand_Konagala

I would recommend that you update your client versions:
pip install elasticsearch

Create this small program to test (elastic-test.py)

from elasticsearch import Elasticsearch


# Create the client instance
client = Elasticsearch(
    [{"host":"localhost", "port":9200}]
)

# Successful response!
print(client.info())

And see if it is returning the correct result

If so, test the same code within Flask and compare the environments.

i have the same error , how can i resove it

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