# PUT Index mapping via curl result an error (Content-Type header fix does not working)

**URL:** <https://discuss.elastic.co/t/put-index-mapping-via-curl-result-an-error-content-type-header-fix-does-not-working/111445>\
**Category:** Elasticsearch\
**Created:** [December 12, 2017, 9:37pm UTC](https://discuss.elastic.co/t/put-index-mapping-via-curl-result-an-error-content-type-header-fix-does-not-working/111445 "2017-12-12T21:37:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![toshi78](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@toshi78](https://discuss.elastic.co/u/toshi78)\
**Post date:** [December 12, 2017, 9:37pm UTC](https://discuss.elastic.co/t/put-index-mapping-via-curl-result-an-error-content-type-header-fix-does-not-working/111445/1 "2017-12-12T21:37:24Z")

</div>

Hi everyone !

I migrated from ES 5 to ES 6, and I've tried to push the following mapping with curl as usual:

```
"mappings" : {
"mee": {
    "properties" : {
        "ind1" : { "type" : "float" },
        "ind2" : { "type" : "float" },
        "ind3" : { "type" : "float" },
        "time" : { "type" : "date", "format" : "HH:mm:ss" },
        "name" : { "type" : "string" },
        "timestamp" : { "type" : "date", "format" : "yyyy-MM-dd HH:mm:ss" },
    }
}

```

With the following command:

> $ curl -XPUT "[http://localhost:9200/mee/](http://localhost:9200/mee/)" -d @config/ESConf/ESUpdate.conf  
> `{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}`

And as the header is necessary I've made the following:

> $ curl -XPUT "[http://localhost:9200/mee/](http://localhost:9200/mee/)" **-H 'Content-Type: application/json'** -d @config/ESConf/ESUpdate.conf  
> `{"error":{"root_cause":[{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}],"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"},"status":500}`

And now I am completely lost... Just don't understand this error... Did I made something wrong ?

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![mujtabahussain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mujtabahussain/32/17514_2.png) [@mujtabahussain](https://discuss.elastic.co/u/mujtabahussain)\
**Post date:** [December 12, 2017, 11:32pm UTC](https://discuss.elastic.co/t/put-index-mapping-via-curl-result-an-error-content-type-header-fix-does-not-working/111445/2 "2017-12-12T23:32:01Z")

</div>

Hey!

So I installed elastic 6.0.1 as confirmed below

```json
http :9200
HTTP/1.1 200 OK
content-encoding: gzip
content-length: 276
content-type: application/json; charset=UTF-8

{
    "cluster_name": "elasticsearch",
    "cluster_uuid": "IvAbUG-HSYaiJLcmjjwUMg",
    "name": "cGwtenD",
    "tagline": "You Know, for Search",
    "version": {
        "build_date": "2017-12-04T09:29:09.525Z",
        "build_hash": "601be4a",
        "build_snapshot": false,
        "lucene_version": "7.0.1",
        "minimum_index_compatibility_version": "5.0.0",
        "minimum_wire_compatibility_version": "5.6.0",
        "number": "6.0.1"
    }
}

```

I copied your mapping json, which has a few syntax errors (missing brackets etc). So the fixed version is here

```json
{
  "mappings": {
    "mee": {
      "properties": {
        "ind1": {
          "type": "float"
        },
        "ind2": {
          "type": "float"
        },
        "ind3": {
          "type": "float"
        },
        "time": {
          "type": "date",
          "format": "HH:mm:ss"
        },
        "name": {
          "type": "string"
        },
        "timestamp": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        }
      }
    }
  }
}

```

However the type for `name` is incorrect which should either be `keyword` or `text` as mentioned here in [Core Data Types](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html#_core_datatypes)

So the fixed mapping for name (I just randomly chose `text`)

```json
"name": {
  "type": "text"
},

```

With the fixed mapping when I tried

```bash
$> curl -XPUT 'localhost:9200/mee' -H 'Content-Type: application/json' -d @mapping.json

```

I got

```json
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "mee"
}

```

Try fixing your `JSON` errors first and see if that works!

---

<div class="post-metadata">

**Author:** ![toshi78](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@toshi78](https://discuss.elastic.co/u/toshi78)\
**Post date:** [December 13, 2017, 9:02pm UTC](https://discuss.elastic.co/t/put-index-mapping-via-curl-result-an-error-content-type-header-fix-does-not-working/111445/3 "2017-12-13T21:02:05Z")

</div>

Yep I've missed few things on my mapping...

On ES 5 when I made something wrong, I had a json parse error or a pretty clear error. Here that's the first time I see this kind of error... Maybe this is because of the new header requirement on ES 6.

Thank you anyway 🙂

---

<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 10, 2018, 9:02pm UTC](https://discuss.elastic.co/t/put-index-mapping-via-curl-result-an-error-content-type-header-fix-does-not-working/111445/4 "2018-01-10T21:02:37Z")

</div>

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