I was using python to insert some data to elasticsearch, the elasticsearch version is > 6.0. the code can be seen as:
from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch( "localhost:9200" ) 
from elasticsearch import TransportError
data = {
    "http_code" : "404",
    "count" : "10"
}
try:
    es.index(index="http_code", doc_type="error_code",body=data)
except TransportError as e:
    print(e.info)
but we will have problem like:{u'status': 406, u'error': u'Content-Type header [] is not supported'}
I have searched that in the new elastic search version it need to set the header,  for example in the command line we can use:
" curl -XPUT 'localhost:9200/customer/external/1?pretty' -d '{ "name": "John Doe" }'
but in python how can we set the header? anyone knows about that?
TRY THIS:
python -m pip install --upgrade 'elasticsearch>=7.16,<8'
it should resolve your problem.
elasticsearch.index error with header not supported