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

I'm new to elasticsearch, this is literally my first cluster. I am using Windows 10 and was trying to run the following at the command line:

C:\elastic>curl -X POST "localhost:9200/students/student/1?pretty" -d '{"joao":"pedro","bob":"michael"}'

And I got the following output:

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

After a little of research, I tried the following:

curl -XPOST "localhost:9200/students/student/1?pretty" -H'Content-Type: application/json' -d '{"joao":"pedro","bob":"michael"}'

And I got the following output:

{
  "error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
  "status" : 406
}
curl: (6) Could not resolve host: application

How the heck I resolve this problem? Anyone known ANYTHING about it?

Welcome!

Windows is a pain when it comes to curl. You should better use Kibana.

Have a look at this: Content-Type header [application/x-www-form-urlencoded] is not supported, "status":406

Thank you for the suggestion! But I am still going to search for someway of resolve using curl, I have seen 3 tutorials of people using curl and working perfectly.

I just don't understand wtf is happening with my computer. Even so, thanks very much!

So... I made some more research and I discovered that status 406 means that elastic can't use the input, but I am using json, does this means that my elasticsearch is having trouble understanding json?

If this is the case, what should I do?

The problem is that the content type is not correctly sent to elasticsearch. You need to read your curl tool help I believe.

I did it!

curl -H "Content-Type: application/json" --data @hello1.json http://localhost:9200/students/student/2?pretty
2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.