# Mapping in ELK 6.1 with the Ruby Rest Client

**URL:** <https://discuss.elastic.co/t/mapping-in-elk-6-1-with-the-ruby-rest-client/114733>\
**Category:** Elasticsearch\
**Created:** [January 9, 2018, 4:16pm UTC](https://discuss.elastic.co/t/mapping-in-elk-6-1-with-the-ruby-rest-client/114733 "2018-01-09T16:16:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1243](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@paul1243](https://discuss.elastic.co/u/paul1243)\
**Post date:** [January 9, 2018, 4:16pm UTC](https://discuss.elastic.co/t/mapping-in-elk-6-1-with-the-ruby-rest-client/114733/1 "2018-01-09T16:16:39Z")

</div>

Hi,  
With the latest changes from the ELK 6.1.1 on the Removal of Mapping types, my ruby code doesn't work to create the mapping. Could you please let me know if I am doing anything wrong the mapping created in json file.  
Below is the code snippet:

require 'rest\_client'  
require 'json'

def create\_mapping  
file = File.read('test.json')  
RestClient.put '[http://localhost:9200/testing](http://localhost:9200/testing)', file  
end

test.json consists as below:

> {  
> "mappings": {  
> "features": {  
> "properties": {  
> "@timestamp": {  
> "type": "date",  
> "format": "dateOptionalTime"  
> },  
> "build\_number": {  
> "type": "integer",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "job\_name": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> }  
> }  
> }  
> }  
> }

The same mapping works fine on the Kibana dev tools with the PUT method, but doesn't work with the Ruby client.

The error message returned from ruby rest client is "406 Not Acceptable (RestClient::NotAcceptable)"

Could you please let me know how do I fix this issue. Thanks !

---

<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:** [January 9, 2018, 4:32pm UTC](https://discuss.elastic.co/t/mapping-in-elk-6-1-with-the-ruby-rest-client/114733/2 "2018-01-09T16:32:50Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

Do you set in your client somewhere the `Content-Type`?

---

<div class="post-metadata">

**Author:** ![paul1243](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@paul1243](https://discuss.elastic.co/u/paul1243)\
**Post date:** [January 10, 2018, 1:13pm UTC](https://discuss.elastic.co/t/mapping-in-elk-6-1-with-the-ruby-rest-client/114733/3 "2018-01-10T13:13:13Z")

</div>

Thanks for your reply @dadoonet, after adding the content type, it works. 🙂

---

<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:** [February 7, 2018, 1:13pm UTC](https://discuss.elastic.co/t/mapping-in-elk-6-1-with-the-ruby-rest-client/114733/4 "2018-02-07T13:13:44Z")

</div>

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