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

**URL:** https://discuss.elastic.co/t/curl-via-script-content-type-header-application-x-www-form-urlencoded-is-not-supported-status-406-curl-6-could-not-resolve-host-application/112426
**Category:** Elasticsearch
**Created:** [December 19, 2017, 11:50am UTC](https://discuss.elastic.co/t/curl-via-script-content-type-header-application-x-www-form-urlencoded-is-not-supported-status-406-curl-6-could-not-resolve-host-application/112426 "2017-12-19T11:50:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)
#### Post date: [December 19, 2017, 11:50am UTC](https://discuss.elastic.co/t/curl-via-script-content-type-header-application-x-www-form-urlencoded-is-not-supported-status-406-curl-6-could-not-resolve-host-application/112426/1 "2017-12-19T11:50:25Z")

</div>

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:  
#!/bin/bash

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

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

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

# firing the command
$mycommand

```

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](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](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:

`{"took":14,"timed_out":false,"_shards":{"total":129,"successful":129,"skipped":128,"failed":0},"hits":{"total":78,"max_score":0.0,"hits":[]}}`

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

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

---

<div class="post-metadata">

### Author: ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)
#### Post date: [December 19, 2017, 12:52pm UTC](https://discuss.elastic.co/t/curl-via-script-content-type-header-application-x-www-form-urlencoded-is-not-supported-status-406-curl-6-could-not-resolve-host-application/112426/2 "2017-12-19T12:52:22Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)
#### Post date: [December 19, 2017, 1:49pm UTC](https://discuss.elastic.co/t/curl-via-script-content-type-header-application-x-www-form-urlencoded-is-not-supported-status-406-curl-6-could-not-resolve-host-application/112426/3 "2017-12-19T13:49:17Z")

</div>

found a solution. putting the header hardcoded is working:

```
#!/bin/bash

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

# 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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 16, 2018, 1:49pm UTC](https://discuss.elastic.co/t/curl-via-script-content-type-header-application-x-www-form-urlencoded-is-not-supported-status-406-curl-6-could-not-resolve-host-application/112426/4 "2018-01-16T13:49:33Z")

</div>

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