# Java/RestClient Render/Dump/Log the BulkRequest issued

**URL:** <https://discuss.elastic.co/t/java-restclient-render-dump-log-the-bulkrequest-issued/272806>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 12, 2021, 12:19pm UTC](https://discuss.elastic.co/t/java-restclient-render-dump-log-the-bulkrequest-issued/272806 "2021-05-12T12:19:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibexit](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@ibexit](https://discuss.elastic.co/u/ibexit)\
**Post date:** [May 12, 2021, 12:19pm UTC](https://discuss.elastic.co/t/java-restclient-render-dump-log-the-bulkrequest-issued/272806/1 "2021-05-12T12:19:24Z")

</div>

We´re able to access the RequestBody sent by the client for searches - pretty easy.

But is there a way to have this for BulkRequests too? Or in other words: I need access to the \_bulk payloads compiled/send by the java-rest-client and save them into files for reasons.

My Code:

```auto
     BulkRequest request = new BulkRequest();
        request.add(new IndexRequest("posts").id("1")
                .source(XContentType.JSON,"foo", "ba1"));
        request.add(new IndexRequest("posts").id("2")
                .source(XContentType.JSON,"foo", "bar2"));
        request.add(new IndexRequest("posts").id("3")
                .source(XContentType.JSON,"foo", "bar3"));

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStreamStreamOutput osso = new OutputStreamStreamOutput(baos);

        request.writeTo(osso);
        String requestAsString = baos.toString("UTF-8");

```

The Output:

```auto
     ���� ����posts _doc1 
{"foo":"ba1"} �������� �������� ����posts _doc2 {"foo":"bar2"} �������� �������� ����posts _doc3 {"foo":"bar3"} �������� ��������   

```

Expected/Desired Output:

```auto
{ "index" : { "_index" : "posts", "_id" : "1" } }
{ "foo" : "bar1" }
{ "index" : { "_index" : "posts", "_id" : "2" } }
{ "foo" : "bar2" }
{ "index" : { "_index" : "posts", "_id" : "3" } }
{ "foo" : "bar3" }

```

Anyone eager to help? Thanks in advance!

---

<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:** [June 9, 2021, 12:19pm UTC](https://discuss.elastic.co/t/java-restclient-render-dump-log-the-bulkrequest-issued/272806/2 "2021-06-09T12:19:47Z")

</div>

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