# Writing updateMapping method() - odd error returned by ES

**URL:** <https://discuss.elastic.co/t/writing-updatemapping-method-odd-error-returned-by-es/167924>\
**Category:** Elasticsearch\
**Created:** [February 11, 2019, 8:46pm UTC](https://discuss.elastic.co/t/writing-updatemapping-method-odd-error-returned-by-es/167924 "2019-02-11T20:46:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kendra\_Kuivenhoven](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kendra\_Kuivenhoven](https://discuss.elastic.co/u/Kendra_Kuivenhoven)\
**Post date:** [February 11, 2019, 8:46pm UTC](https://discuss.elastic.co/t/writing-updatemapping-method-odd-error-returned-by-es/167924/1 "2019-02-11T20:46:24Z")

</div>

Hi all,

I'm trying to write a method where I can update the mapping of an ElasticSearch index directly from visual studio. I have the mappings stored in json files in my project on visual studio. I import whatever particular mapping I need to update and attempt to post it via a C# curl method. In my method I'm also creating a new index with my new mapping. Upon attempting to create a new index with the new mapping, this error is returned: "{\n "error" : {\n "root\_cause" : [\n {\n "type" : "class\_cast\_exception",\n "reason" : "java.lang.String cannot be cast to java.util.Map"\n }\n],\n "type" : "class\_cast\_exception",\n "reason" : "java.lang.String cannot be cast to java.util.Map"\n },\n "status" : 500\n}\n"

This is not that descriptive of an error so I am not really sure where to look for the problem that is causing this error message to be returned. Any insight would be much appreciated!

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [February 15, 2019, 7:53pm UTC](https://discuss.elastic.co/t/writing-updatemapping-method-odd-error-returned-by-es/167924/2 "2019-02-15T19:53:17Z")

</div>

Can you paste the mapping you are trying to use? It sounds like you supplied a string in a location that ES was expecting a JSON object (which is basically a map, hence the error)

---

<div class="post-metadata">

**Author:** ![Kendra\_Kuivenhoven](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kendra\_Kuivenhoven](https://discuss.elastic.co/u/Kendra_Kuivenhoven)\
**Post date:** [February 15, 2019, 9:21pm UTC](https://discuss.elastic.co/t/writing-updatemapping-method-odd-error-returned-by-es/167924/3 "2019-02-15T21:21:57Z")

</div>

Hi Zachary,

You are correct. I fixed it by moving the string and putting a JSON object there. Thank you though!

---

<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:** [March 15, 2019, 9:22pm UTC](https://discuss.elastic.co/t/writing-updatemapping-method-odd-error-returned-by-es/167924/4 "2019-03-15T21:22:00Z")

</div>

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