• Register
1 vote
350 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?
6 5 3
6,930 points

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

Related questions

0 votes
1 answer 966 views
966 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 mphil 2.3k points
0 votes
1 answer 2.1K views
2.1K views
Problem : Currently I am trying to create a heatmap using a ggmosaic, But I keep facing below error “Error in is.finite(x) : default method not implemented for type 'list'” 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 mphil 2.3k points
0 votes
1 answer 12 views
12 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 Raphael Pacheco 4.9k points