查询 REST put 的问题,一个 elasticsearch

problem to make a query REST put, a elasticsearch

我想发送格式为 json 的数据,但我做不到

我正在使用 elasticsearch 版本 7.0.1 和 curl 7.64,我在 windows 10

curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
  "name": "John Doe"
}
'

我有这样的错误信息:

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

}

curl: (6) Could not resolve host: application

curl: (3) URL using bad/illegal format or missing URL

关于Windows,你需要到处使用双引号,而不是单引号:

curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H "Content-Type: application/json" -d "{ \"name\": \"John Doe\" }"