# "not\_x\_content\_exception" while trying to PUT simple file with column mappings into ES via cURL

**URL:** <https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537>\
**Category:** Elasticsearch\
**Created:** [October 11, 2017, 11:39am UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537 "2017-10-11T11:39:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikhail](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mikhail](https://discuss.elastic.co/u/Mikhail)\
**Post date:** [October 11, 2017, 11:39am UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/1 "2017-10-11T11:39:43Z")

</div>

Good day!

I'm a newbie in ELK and got stuck on the task that seemed to be a simple one on the first sight but that is not how it turned out.

What am I trying to do:  
I have a table with test data in MS SQL Server and I want to setup data transfer from it via Logstash into Elasticsearch. I have successfully performed this task and data have reached the desired index in ES. The more we get the more we want. And I decided to setup explicit mappings for columns to make sure that data will be transferred from source table into ES index in desired format. To do this, I have created **companies\_list.mapping** file with the following content:

```
{
    "companies_list": {
    "properties": {
        "id": {
            "index": "not_analyzed",
            "type": "string"
        },
        "number_of_employees": {
            "type": "long"
        },
        "name": {
            "index": "analyzed",
            "type": "string"
        },
        "description": {
            "index": "analyzed",
            "type": "string"
        },
        "homepage": {
            "index": "not_analyzed",
            "type": "string"
        },
        "location": {
            "geohash": true,
            "type": "geo_point"
        }
    }
  }
}

```

And trying to upload mappings from this file into ES using cURL. Sequence of my actions:

a. Delete all indicies in ES with command:

```
curl -X DELETE "http://localhost:9220/_all"

```

Result:

```
{"acknowledged":true}

```

b. Create index in ES:

```
curl -X PUT http://localhost:9220/companies_list

```

Result:

```
{"acknowledged":true}

```

c. Trying to PUT mappings from file:

```
curl -X PUT "http://localhost:9220/companies_list/_mapping/companies_list" -d "D:\ELK\mappings\companies_list.mapping"

```

Result:

```
{"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}

```

I have googled this error but have not found the answer. Any suggestions on this?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 11, 2017, 12:01pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/2 "2017-10-11T12:01:14Z")

</div>

You are missing the content type

Add -H 'Content-Type: application/json'

---

<div class="post-metadata">

**Author:** ![Mikhail](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mikhail](https://discuss.elastic.co/u/Mikhail)\
**Post date:** [October 11, 2017, 12:45pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/3 "2017-10-11T12:45:21Z")

</div>

Thanks a lot for quick reply!  
I have added this part into cURL command and now it looks like this:

```
curl -X PUT "http://localhost:9220/companies_list/_mapping/companies_list" -d "D:\ELK\mappings\companies_list.mapping" -H "Content-Type: application/json"

```

But it doesn't make sense. Still getting the same error.

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [October 11, 2017, 1:01pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/4 "2017-10-11T13:01:46Z")

</div>

what does `companies_list.mapping` look like?

---

<div class="post-metadata">

**Author:** ![Mikhail](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mikhail](https://discuss.elastic.co/u/Mikhail)\
**Post date:** [October 11, 2017, 1:15pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/5 "2017-10-11T13:15:47Z")

</div>

Content of this file is provided in the first post. I have added filename and highlighted it there.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 11, 2017, 1:22pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/6 "2017-10-11T13:22:16Z")

</div>

I think you need to use `@` sign to reference a file in curl. Better to read curl manual. Should be something like

```
-d "@path/to/file"
```

---

<div class="post-metadata">

**Author:** ![Mikhail](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Mikhail](https://discuss.elastic.co/u/Mikhail)\
**Post date:** [October 11, 2017, 1:34pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/7 "2017-10-11T13:34:02Z")

</div>

Thanks!  
@ sign in the start of the path has moved me to the next step! (name of some datatypes in the file). I think I will be able to resolve these new errors by myself.  
So, the correct cURL command was:

```
curl -X PUT "http://localhost:9220/companies_list/_mapping/companies_list" -d "@D:\ELK\mappings\companies_list.mapping"
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 11, 2017, 2:16pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/8 "2017-10-11T14:16:41Z")

</div>

Better to use Kibana dev console. Much easier IMO.

---

<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:** [November 8, 2017, 2:17pm UTC](https://discuss.elastic.co/t/not-x-content-exception-while-trying-to-put-simple-file-with-column-mappings-into-es-via-curl/103537/9 "2017-11-08T14:17:02Z")

</div>

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