Radha
Radha

Reputation: 61

Content type header is not supported error message

I have the following curl command on elasticsearch and it has token based authentication.

curl -k -H "Authorization :Bearer eH8AII7j3e81zfvcIKe715FXsjZ5or3" -XPUT https://localhost:9200/school/student/1 -d"{/"name/":/"mohan/"}"

But it is throwing the following error.

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

Upvotes: 1

Views: 2896

Answers (1)

Val
Val

Reputation: 217514

You need to also provide the Content-Type HTTP header in your request:

curl -k -H "Content-Type: application/json" -H "Authorization :Bearer eH8AII7j3e81zfvcIKe715FXsjZ5or3" -XPUT https://localhost:9200/school/student/1 -d"{\"name\":\"mohan\"}"
                          ^
                          |
                   add this header

Also you need to escape the double quotes with backslashes \ not forward slashes /

Upvotes: 2

Related Questions