# Elasticsearch 8 Client is giving error The following method did not exist: ‘org.elasticsearch.client.RequestOptions$Builder org.elasticsearch.client.RequestOptions$Builder.removeHeader(java.lang.String)’

**URL:** https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [June 7, 2023, 6:49pm UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467 "2023-06-07T18:49:22Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Skander\_Mansouri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skander_mansouri/32/121964_2.png) [@Skander\_Mansouri](https://discuss.elastic.co/u/Skander_Mansouri)
#### Post date: [June 7, 2023, 6:49pm UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/1 "2023-06-07T18:49:22Z")

</div>

I have copied exactly the same steps as the documentation [elastic8 docs](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/installation.html)

```auto
@Bean
public ElasticsearchClient getElasticSearchClient(){
  RestClient restClient = RestClient.builder(
          new HttpHost("", 9200)).build();

// Create the transport with a Jackson mapper
  ElasticsearchTransport transport = new RestClientTransport(
          restClient, new JacksonJsonpMapper());

// And create the API client
  ElasticsearchClient client = new ElasticsearchClient(transport);
  
  return client;
}

```

and I'm receiving this error

```auto
Error it gives

An attempt was made to call a method that does not exist. The attempt was made from the following location:

   co.elastic.clients.transport.rest_client.RestClientOptions.addBuiltinHeaders(RestClientOptions.java:170)

The following method did not exist:

   'org.elasticsearch.client.RequestOptions$Builder org.elasticsearch.client.RequestOptions$Builder.removeHeader(java.lang.String)'

The method's class, org.elasticsearch.client.RequestOptions$Builder, is available from the following locations:

```

Saw the library of rest\_client that was causing the issue and it's 7.2.  
my pom is the following

```auto

  <parent>
    <artifactId>spring-boot-starter-parent</artifactId>
    <groupId>org.springframework.boot</groupId>
    <version>2.6.2</version>
  </parent>

  <properties>
    <apache.beam.version>2.39.0</apache.beam.version>
    <java.version>11</java.version>
    <elasticsearch-java.version>7.17.0</elasticsearch-java.version>
    <jakarta-json-api.version>2.0.1</jakarta-json-api.version>

    <!-- testing... -->

  </properties>

  <version>latest-SNAPSHOT</version>
  
  <dependencies>
    <dependency>
      <groupId>co.elastic.clients</groupId>
      <artifactId>elasticsearch-java</artifactId>
      <version>${elasticsearch-java.version}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.12.3</version>
    </dependency>

```

---

<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: [June 7, 2023, 7:03pm UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/2 "2023-06-07T19:03:12Z")

</div>

Welcome! Have a look at the dependency tree.

It will probably show you that you are not using the right version of the low level client.

---

<div class="post-metadata">

### Author: ![Skander\_Mansouri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skander_mansouri/32/121964_2.png) [@Skander\_Mansouri](https://discuss.elastic.co/u/Skander_Mansouri)
#### Post date: [June 7, 2023, 7:24pm UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/3 "2023-06-07T19:24:20Z")

</div>

Looks like it's the apache beam who's downloading the dependency of

```auto
- org.apache.beam:beam-sdks-java-io-elasticsearch:jar:2.39.0:compile
[INFO] | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.5:compile
[INFO] | +- org.apache.httpcomponents:httpcore-nio:jar:4.4.15:compile
[INFO] | \- org.elasticsearch.client:elasticsearch-rest-client:jar:7.15.2:compile

```

---

<div class="post-metadata">

### Author: ![Skander\_Mansouri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skander_mansouri/32/121964_2.png) [@Skander\_Mansouri](https://discuss.elastic.co/u/Skander_Mansouri)
#### Post date: [June 7, 2023, 7:41pm UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/4 "2023-06-07T19:41:50Z")

</div>

I made the exclusion from apache beam

```auto
  <dependency>
      <artifactId>beam-sdks-java-io-elasticsearch</artifactId>
      <groupId>org.apache.beam</groupId>
      <version>${apache.beam.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.elasticsearch.client</groupId>
          <artifactId>elasticsearch-rest-client</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

```

my dependency tree looks like

```auto
 +- co.elastic.clients:elasticsearch-java:jar:8.8.0:compile
[INFO] | +- org.elasticsearch.client:elasticsearch-rest-client:jar:7.15.2:compile
[INFO] | \- org.eclipse.parsson:parsson:jar:1.0.0:compile

```

and still receives the same error  
@dadoonet

---

<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: [June 7, 2023, 8:01pm UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/5 "2023-06-07T20:01:59Z")

</div>

You need to use 7.17.10 or 7.17.11 for both clients.

---

<div class="post-metadata">

### Author: ![Skander\_Mansouri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skander_mansouri/32/121964_2.png) [@Skander\_Mansouri](https://discuss.elastic.co/u/Skander_Mansouri)
#### Post date: [June 7, 2023, 8:10pm UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/6 "2023-06-07T20:10:17Z")

</div>

does that mean the 8.8 doesn't work or what? I'm not sure I get your answer

---

<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: [June 8, 2023, 2:46am UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/7 "2023-06-08T02:46:19Z")

</div>

In your Pom, you set 7.17.0 as the version. So I guessed you are using a 7.17.0 version. Am I wrong?

What is your Elasticsearch server version?

---

<div class="post-metadata">

### Author: ![Skander\_Mansouri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skander_mansouri/32/121964_2.png) [@Skander\_Mansouri](https://discuss.elastic.co/u/Skander_Mansouri)
#### Post date: [June 8, 2023, 7:07am UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/8 "2023-06-08T07:07:38Z")

</div>

my bad. I switched my pom to using the 8.8 version. copied the previous pom

---

<div class="post-metadata">

### Author: ![Skander\_Mansouri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skander_mansouri/32/121964_2.png) [@Skander\_Mansouri](https://discuss.elastic.co/u/Skander_Mansouri)
#### Post date: [June 8, 2023, 7:09am UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/9 "2023-06-08T07:09:42Z")

</div>

the ES version I'm using is 8.  
the lib version is 8.8  
the rest-client downloaded via the lib is 7.5  
the issue is still there

---

<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: [June 8, 2023, 7:32am UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/10 "2023-06-08T07:32:58Z")

</div>

> the rest-client downloaded via the lib is 7.5

No. It's not the lib. It's probably a problem with the spring parent.

So you should "force" the low level client:

```auto
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-client</artifactId>
    <version>8.8.0</version>
</dependency>

```

---

<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 6, 2023, 7:32am UTC](https://discuss.elastic.co/t/elasticsearch-8-client-is-giving-error-the-following-method-did-not-exist-org-elasticsearch-client-requestoptions-builder-org-elasticsearch-client-requestoptions-builder-removeheader-java-lang-string/335467/11 "2023-07-06T07:32:59Z")

</div>

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