我在Elasticsearch上有以下curl命令,它具有基于令牌的身份验证。
curl -k -H "Authorization :Bearer eH8AII7j3e81zfvcIKe715FXsjZ5or3" -XPUT https://localhost:9200/school/student/1 -d"{/"name/":/"mohan/"}"
但是它引发了以下错误。
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
答案 0 :(得分:1)
您还需要在请求中提供Content-Type
HTTP header:
curl -k -H "Content-Type: application/json" -H "Authorization :Bearer eH8AII7j3e81zfvcIKe715FXsjZ5or3" -XPUT https://localhost:9200/school/student/1 -d"{\"name\":\"mohan\"}"
^
|
add this header
此外,您还需要使用反斜杠\
而不是正斜杠/
来排除双引号