# Update jsonString with UpdateRequest through new java client\[8+ version\]

**URL:** <https://discuss.elastic.co/t/update-jsonstring-with-updaterequest-through-new-java-client-8-version/350855>\
**Category:** Elasticsearch\
**Created:** [January 11, 2024, 12:31pm UTC](https://discuss.elastic.co/t/update-jsonstring-with-updaterequest-through-new-java-client-8-version/350855 "2024-01-11T12:31:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pankaj\_sen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pankaj_sen/32/130706_2.png) [@pankaj\_sen](https://discuss.elastic.co/u/pankaj_sen)\
**Post date:** [January 11, 2024, 12:31pm UTC](https://discuss.elastic.co/t/update-jsonstring-with-updaterequest-through-new-java-client-8-version/350855/1 "2024-01-11T12:31:47Z")

</div>

Getting below error while trying to update json string through update request.

`[x_content_parse_exception] [1:8] [UpdateRequest] doc doesn't support values of type: VALUE_STRING`

Below is my code snnipt

```auto
client.update(getUpdateRequest(id, index, jsonString), String.class);
private UpdateRequest getUpdateRequest(String id, String index, String jsonString) {
        return UpdateRequest.of(indexRequest -> indexRequest
                .index(index)
                .id(id)
                .refresh(Refresh.WaitFor)
                .waitForActiveShards(activeShards -> activeShards.count(1))
                .docAsUpsert(Boolean.TRUE)
                .doc(jsonString));
    }

```

---

<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 8, 2024, 12:32pm UTC](https://discuss.elastic.co/t/update-jsonstring-with-updaterequest-through-new-java-client-8-version/350855/2 "2024-02-08T12:32:18Z")

</div>

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