Curl via script: Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}curl: (6) Could not resolve host: application


Hi there,

I upgraded to 6.1.0 - coming from 5.1.2.
My script was running fine on 5.1.2 but I have problems with using scripted curl with 6.1.0. Maybe there is sth. wrong on my dev environment. Haven't reverted to 5.1.2. for proving that anything works there.

ok, here is my script:

#setting some vars
curlArguments="-XGET http://localhost:9200/*/_search -H \"Content-Type: application/json\""

# building the command
mycommand="curl $curlArguments --data \"@$curlDataFile\""

# output of command
echo command is:
echo $mycommand
echo "now firing command"

# firing the command

This is the content of the probe.curl file

  "query": {
    "bool": {
      "must": [
          "query_string": {
            "query": "*",
            "analyze_wildcard": true
          "range": {
            "@timestamp": {
              "gte": "now/m-5m",
              "lte": "now/m",
              "format": "epoch_millis"
      "must_not": []
  "size": "0"

When running, I got following output with error message:

command is:
curl -XGET http://localhost:9200/*/_search -H "Content-Type: application/json" --data "@./probe.curl"

now firing command
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}curl: (6) Could not resolve host: application; Der Name oder der Dienst ist nicht bekannt

The strange thing is, when I take the built command line

curl -XGET http://localhost:9200/*/_search -H "Content-Type: application/json" --data "@./probe.curl"

and run it directly from shell it works fine and I get following output:


Can anyone point to the root cause? I don't understand it.

Elasticsearch log is not showing anything, either on good or bad run.


Yes, I reverted my VM to 5.1.2. Still working. What do I need to change to get it running with 6.1.0?


found a solution. putting the header hardcoded is working:


#setting some vars
curlArguments="-XGET http://localhost:9200/*/_search"

# building the command
myargs="$curlArguments ""--data \"@$curlDataFile\""
mycommand="curl $myargs"
curl -H 'Content-Type: application/json' $curlArguments --data "@$curlDataFile"

So it was just a quoting issue with the header which is needed by ES 6.x.

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.