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

本文介绍了一种在使用curl命令向Elasticsearch上传文档时遇到的问题及解决方案。当尝试用curl-XPOST命令发送JSON格式的数据到Elasticsearch时,由于Content-Type设置不正确导致返回错误406。文章提供了正确的curl命令示例,包括如何设置Content-Type为application/json。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述

curl -XPOST  'localhost:9200/books/es/1' -d '{"title":"Elasticsearch Server", "pubilished":2013}'

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


需要指定对应的header头: -H "Content-Type: application/json"

解决方法

curl -H "Content-Type: application/json" -XPOST 'localhost:9200/books/es/1' -d '{"title":"Elasticsearch Server", "publicshed":2013}'


摘自:https://blog.youkuaiyun.com/dtiove/article/details/78870607

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值