• Register
1 vote

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?
6 5 3
6,930 points

Please log in or register to answer this question.

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.


  "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
9 7 4
38,600 points

Related questions

0 votes
1 answer 1.3K views
Problem : I am very new to Curl. I have recently started learning Curl. Whenever I try to connect to the Elasticsearch using below command curl http://localhost:9200 it is working properly. But when I try to run the following command curl http://IpAddress: ... showing me below error “Curl: (7) failed to connect to localhost port 9200: connection refused” How can I resolve above error?
asked Feb 20, 2020 mphil 2.3k points
0 votes
1 answer 220 views
Problem : I am facing an issue with a systemd config for ElasticSearch as follows: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
asked Nov 18, 2019 peterlaw 6.9k points
0 votes
1 answer 52 views
Problem : I am getting bellow Wordpress error download failed. error:0d0890a1:asn1 encoding routines:asn1_verify:unknown message digest algorithm
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
1 answer 20 views
Problem: I am a na&iuml;ve to Java, Jsp, Servlet and trying to make a very small registration program with the database. But while trying to run this I am facing below errors: HTTP Status 405 - HTTP method GET is not supported by this URL type Status report message HTTP ... </welcome-file>     </welcome-file-list> </web-app> I am looking for Java expert who can help me in fixing above error.
asked Jul 29, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 2.9K views
Problem : Currently I am trying to create a heatmap using a ggmosaic, But I keep facing below error &ldquo;Error in is.finite(x) : default method not implemented for type 'list'&rdquo; My Configuration is Windows, RStudio, R version mostly one before a most recent, and ggmosaic Ver 0.1.2 How can I fix the above error?
asked Feb 20, 2020 mphil 2.3k points