elasticsearch - 不支持内容类型 header

标签 elasticsearch curl libcurl

我正在关注 elasticsearch 的这个链接。

https://www.elastic.co/blog/a-practical-introduction-to-elasticsearch

我正在尝试按照 curl 发布 json 数据。

curl -XPOST "http://localhost:9200/shakespeare/_bulk?pretty" --data-binary @D:\data\shakespeare.json

但是我得到如下错误:

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

最佳答案

需要在header中设置content type为application/json:

curl -XPOST -H "Content-Type: application/json" "http://localhost:9200/shakespeare/_bulk?pretty" --data-binary @D:\data\shakespeare.json

关于elasticsearch - 不支持内容类型 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51378099/

相关文章:

elasticsearch - 如何在连续Elasticsearch转换中动态更改目标索引?

api - Elasticsearch:聚合嵌套对象

elasticsearch - 格式化elasticsearch结果

c - 丢弃来自 libcurl 的响应数据

curl - NSS : client certificate not found (nickname not specified)?

ruby - ElasticSearch/Ruby - 返回日期直方图格式?

尽管 HTTP 代码 200,PHP cURL 返回空 header 和正文

curl - 将 cURL 与两个匹配范围结合使用

php - 服务器可以阻止 curl 请求吗?

使用 libcurl 更改内容类型