"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported"

问题:

终端操作e s的时候出现这个问题

curl -XGET 'http://localhost:9200/_count?pretty' -d '
{
    "query": {
        "match_all": {}
    }
}
'

报错:

{

  "error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",

  "status" : 406

}

"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported"

改:

curl -XGET 'localhost:9200/_count?pretty' -H 'content-Type:application/json' -d '

{

"query":{

"match_all":{}

}

返回成功:

"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported"

 reason:

这个问题,是在报文Content-type的参数:application/x-www-form-urlencoded不支持Json发送。需要改成application/Json
所以需要添加参数 ; -H ‘Content-Type: application/json’