# Alpha 4 new java http client

**URL:** <https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933>\
**Category:** Elasticsearch\
**Created:** [July 7, 2016, 9:47am UTC](https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933 "2016-07-07T09:47:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [July 7, 2016, 9:47am UTC](https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933/1 "2016-07-07T09:47:56Z")

</div>

Hi, I am playing around with the new java client introduced in alpha 4. I was wondering why in the performRequest method there are all these mandatory fields. I need to provide a Map with params, I need to provide at least one header. This feels a bit weird. Now I have to create a call like this:

```
    Response response = client.performRequest(
            "GET",
            "_cluster/health",
            new Hashtable<>(),
            null,
            new BasicHeader("test", "test"));

```

In this case it would be enough to do something like this:

```
    Response response = client.performRequest(
            "GET",
            "_cluster/health");

```

Is it expected that I send a specific Header with every request?

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [July 7, 2016, 10:13am UTC](https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933/2 "2016-07-07T10:13:47Z")

</div>

Hi Jettro,  
we went this way to keep things simple and avoid having many different variants of the same method with all the possible combinations of arguments. But about headers, that is a vararg, which means that you can happily omit it. You do have to provide an empty map though and `null` for the body as follows, which I agree it is not that nice:

```auto
Response response = client.performRequest(
            "GET",
            "_cluster/health",
            Collections.emptyMap(),
            null);

```

We could make this better and add a shortcut with no body and no parameters for this common case. My initial worry was that then people may also ask for another method with body but no parameters, and another one with parameters but no body. That feels like too much.

Do you see what I mean?

Cheers  
Luca

---

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [July 7, 2016, 2:44pm UTC](https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933/3 "2016-07-07T14:44:08Z")

</div>

Yes I understand what you mean thanks, it just feels strange to provide a null 🙂.

Thanks for explaining.

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [July 7, 2016, 3:01pm UTC](https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933/4 "2016-07-07T15:01:01Z")

</div>

Would you mind opening an issue so we can discuss this? Otherwise I will do it on your behalf 😉

---

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [July 7, 2016, 7:33pm UTC](https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933/5 "2016-07-07T19:33:32Z")

</div>

No problem, here it is:

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

---

<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:** [July 5, 2017, 10:37pm UTC](https://discuss.elastic.co/t/alpha-4-new-java-http-client/54933/6 "2017-07-05T22:37:17Z")

</div>


