【elasticsearch7】{“error“:“Content-Type header [application/x-www-form-urlencoded] is not supported“
报错内容
执行内容:
curl -X PUT "172.31.254.22:9200/test" -d '
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"age": {
"type": "long"
}
}
}
}'
报错内容:
{
"error": "Content-Type header [application/x-www-form-urlencoded] is not supported",
"status": 406
}
解决方法
需要添加HTTP
头
-H "Content-Type: application/json"
最终修改如下:
curl -H "Content-Type: application/json" -X PUT "172.31.254.22:9200/test" -d '
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"age": {
"type": "long"
}
}
}
}'
参考:https://www.elastic.co/cn/blog/strict-content-type-checking-for-elasticsearch-rest-requests