# prepareDelete returns JsonGenerator error

**URL:** <https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547>\
**Category:** Elasticsearch\
**Created:** [November 29, 2016, 9:11pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547 "2016-11-29T21:11:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzwirek](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mzwirek](https://discuss.elastic.co/u/mzwirek)\
**Post date:** [November 29, 2016, 9:11pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547/1 "2016-11-29T21:11:23Z")

</div>

Hi,

I finally had to give up. I used the following (quite straightforward) code with ES 2.3.5 client:

public static Client eSearchClient;

DeleteResponse response = RuntimeConfiguration.eSearchClient  
.prepareDelete(INDEX\_NAME, DOCUMENT\_TYPE, String.valueOf(serviceProvider.getServiceProviderId()))  
.get();

After upgrading to ES 5.0.0 (and switching to Maven) I keep getting the following exception:  
"Error building toString out of XContent: com.fasterxml.jackson.core.JsonGenerationException: Can not write a field name, expecting a value  
at com.fasterxml.jackson.core.JsonGenerator.\_reportError(JsonGenerator.java:1886)"

My POM for ES looks like that:  
  
org.elasticsearch  
elasticsearch  
5.0.0  
  
  
org.elasticsearch.client  
transport  
5.0.0

I'd appreciate any help.

Kind regards,  
Maciej

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 29, 2016, 9:26pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547/2 "2016-11-29T21:26:36Z")

</div>

> [@mzwirek](#):
>
> "Error building toString out of XContent: com.fasterxml.jackson.core.JsonGenerationException: Can not write a field name, expecting a value  
> at com.fasterxml.jackson.core.JsonGenerator.\_reportError(JsonGenerator.java:1886)"

I don't think we're going to be able to help much without the whole stack trace. Can you post it to a gist or something?

---

<div class="post-metadata">

**Author:** ![mzwirek](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mzwirek](https://discuss.elastic.co/u/mzwirek)\
**Post date:** [November 29, 2016, 9:47pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547/3 "2016-11-29T21:47:50Z")

</div>

Sure, here it is:

> <https://gist.github.com/anonymous/a7a898f1446683bb95bf31bc1b23a898>

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 29, 2016, 10:04pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547/4 "2016-11-29T22:04:44Z")

</div>

Looks like a bug. I filed

> <https://github.com/elastic/elasticsearch/issues/21872>

You should be able to work around it by not calling `toString` on the response. But we'll fix it.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 29, 2016, 10:15pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547/5 "2016-11-29T22:15:47Z")

</div>

Looks like it is fixed in 5.0.1.

---

<div class="post-metadata">

**Author:** ![mzwirek](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mzwirek](https://discuss.elastic.co/u/mzwirek)\
**Post date:** [November 29, 2016, 10:28pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547/6 "2016-11-29T22:28:28Z")

</div>

Yes, in 5.0.1 the problem doesn't appear. And also the work around does work for 5.0.0. Thanks a lot for the help.

---

<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:** [December 27, 2016, 10:28pm UTC](https://discuss.elastic.co/t/preparedelete-returns-jsongenerator-error/67547/7 "2016-12-27T22:28:27Z")

</div>

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