# XContentBuilder

**URL:** <https://discuss.elastic.co/t/xcontentbuilder/340399>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 8, 2023, 7:18pm UTC](https://discuss.elastic.co/t/xcontentbuilder/340399 "2023-08-08T19:18:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![toddcarv](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@toddcarv](https://discuss.elastic.co/u/toddcarv)\
**Post date:** [August 8, 2023, 7:19pm UTC](https://discuss.elastic.co/t/xcontentbuilder/340399/1 "2023-08-08T19:19:00Z")

</div>

With the HLRC we were able to use XContentBuilder. For example:

```auto
XContentBuilder xContentBuilder = // create XContentBuilder;
IndexRequest request = new IndexRequest("index").id(id).source(xContentBuilder);

```

Basically we were creating custom JSON to index. Can you recommend the best way to do this with the new Java API Client? Thanks.

---

<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:** [September 5, 2023, 7:19pm UTC](https://discuss.elastic.co/t/xcontentbuilder/340399/2 "2023-09-05T19:19:24Z")

</div>

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