Programmers learn & share
+1 vote
155 views

Problem :

Getting following error related to content-type header
{"error":"content-type header [application/x-www-form-urlencoded] is not supported","status":406}
How to resolve it?
by (6.9k points)  
reopened by | 155 views

1 Answer

+1 vote
Best answer

Solution :

Please change the enclosing quotes from ' to " also escape the quotation marks " used inside the parameters as below and run the curl command :

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

An alternative is also available 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"
    }
  }
}

After doing that run the curl command as below:

curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d @json.txt
by (36.1k points)  
selected by
2,204 questions
2,608 answers
59 comments
241 users