# Unable to set headers in Java rest client Bulk request

**URL:** <https://discuss.elastic.co/t/unable-to-set-headers-in-java-rest-client-bulk-request/175443>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [April 4, 2019, 2:54pm UTC](https://discuss.elastic.co/t/unable-to-set-headers-in-java-rest-client-bulk-request/175443 "2019-04-04T14:54:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinash\_07](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avinash\_07](https://discuss.elastic.co/u/avinash_07)\
**Post date:** [April 4, 2019, 2:54pm UTC](https://discuss.elastic.co/t/unable-to-set-headers-in-java-rest-client-bulk-request/175443/1 "2019-04-04T14:54:31Z")

</div>

I am following the example provided in the documentation for creating the bulk request using bulkprocessor. However, I am not sure how to pass headers to bulkAsync. I am using X-Pack and would like to send the auth header as part of the bulk request

```
  BulkProcessor.Builder builder = BulkProcessor.builder(client::bulkAsync, listener);
  builder.setBulkActions(500);
  builder.setBulkSize(new ByteSizeValue(1L, ByteSizeUnit.MB));
  builder.setConcurrentRequests(0);
  builder.setFlushInterval(TimeValue.timeValueSeconds(10L));
  builder.setBackoffPolicy(BackoffPolicy.constantBackoff(TimeValue.timeValueSeconds(1L), 3));

```

Documentation link - [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.1/java-rest-high-document-bulk.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.1/java-rest-high-document-bulk.html)

ES version - 6.1.2  
Java version - 1.8

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 4, 2019, 5:41pm UTC](https://discuss.elastic.co/t/unable-to-set-headers-in-java-rest-client-bulk-request/175443/2 "2019-04-04T17:41:32Z")

</div>

This is something to do when you create the Low Level client. Read [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.7/\_basic\_authentication.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.7/_basic_authentication.html)

---

<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:** [May 2, 2019, 5:53pm UTC](https://discuss.elastic.co/t/unable-to-set-headers-in-java-rest-client-bulk-request/175443/3 "2019-05-02T17:53:40Z")

</div>

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