• Register
1 vote
621 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

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.

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 14 views
14 views
Problem: content-type not specified assuming application/x-www-form-urlencoded For 2 days I'm having trouble with my PHP script on my server. I've changed nothing and suddenly it didn't work anymore. Any help will be appreciated..!
asked Feb 25 Umar Ahmad 4.1k points
0 votes
1 answer 1.7K views
1.7K 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 2 views
2 views
Problem Need help to fix this problem, "application/x-www-form-urlencoded json."
asked 4 days ago salim1 32.1k points
0 votes
1 answer 4 views
4 views
Problem: Please let me know any solution regarding this issue .. content-type: application/json
asked 4 days ago Ifra 24.4k points
0 votes
1 answer 20 views
20 views
Problem : Curl : Protocol https not supported or disabled in libcurl
asked Feb 23 Shovo210 13.2k points
0 votes
1 answer 4 views
4 views
Problem: Please help me to solve it. what is the value stored at x, given the statements:?
asked Mar 23 Ifra 24.4k points
0 votes
1 answer 2 views
2 views
Problem: As I previously stated in my question, I am having difficulty learning. Could someone help assist me in completing my project
asked Mar 30 tuhin1 47.2k points
0 votes
1 answer 2 views
2 views
Problem: As I previously stated in my question, I am having difficulty learning. Could someone help assist me in completing my project?
asked Apr 1 rakib1 51.3k points