Content-Type header [application/x-www-form-urlencoded] is not supported [duplicate] Content-Type header [application/x-www-form-urlencoded] is not supported [duplicate] elasticsearch elasticsearch

Content-Type header [application/x-www-form-urlencoded] is not supported [duplicate]


After changing the enclosing quotes from ' to ", escape the quotation marks " used inside the parameters as below:

curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d "{\"query\": {\"simple_query_string\" : {\"fields\" : [\"content\"], \"query\" : \"foo bar -baz\"}}}"

An alternative is to put the json into a file, and use the @ prefix for the parameters.

json.txt

{  "query": {    "simple_query_string" : {       "fields" : ["content"],       "query" : "foo bar -baz"    }  }}

and run curl as below:

curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d @json.txt