# Node: http://boardoftrustees-elk.kb.westeurope.azure.elastic-cloud.com:9243/, status: 400, \[es/indices.create\] Expecting JSON data but response content-type is: application/octet-stream

**URL:** <https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 22, 2024, 8:25pm UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024 "2024-05-22T20:25:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fsk/32/134612_2.png) [@fsk](https://discuss.elastic.co/u/fsk)\
**Post date:** [May 22, 2024, 8:25pm UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024/1 "2024-05-22T20:25:35Z")

</div>

Hello guys. I have a project using spring boot and elastic cloud on azure.

When i run command mvn clean install i have an error like below.

```auto
Caused by: co.elastic.clients.transport.TransportException: node: http://trustboard-elk.kb.westeurope.azure.elastic-cloud.com:9243/, status: 400, [es/indices.create] Expecting JSON data but response content-type is: application/octet-stream
	at co.elastic.clients.transport.ElasticsearchTransportBase.checkJsonContentType(ElasticsearchTransportBase.java:471) ~[elasticsearch-java-8.13.2.jar:na]
	at co.elastic.clients.transport.ElasticsearchTransportBase.getApiResponse(ElasticsearchTransportBase.java:334) ~[elasticsearch-java-8.13.2.jar:na]
	at co.elastic.clients.transport.ElasticsearchTransportBase.performRequest(ElasticsearchTransportBase.java:147) ~[elasticsearch-java-8.13.2.jar:na]
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.create(ElasticsearchIndicesClient.java:277) ~[elasticsearch-java-8.13.2.jar:na]
	at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.lambda$doCreate$0(IndicesTemplate.java:145) ~[spring-data-elasticsearch-5.3.0.jar:5.3.0]
	at org.springframework.data.elasticsearch.client.elc.ChildTemplate.execute(ChildTemplate.java:71) ~[spring-data-elasticsearch-5.3.0.jar:5.3.0]
	... 65 common frames omitted

```

```auto
    @Override
    @NonNull
    public ClientConfiguration clientConfiguration() {

        return ClientConfiguration.builder()
                .connectedTo("trustboard-elk.kb.westeurope.azure.elastic-cloud.com:9243")
                .withHeaders(() -> {
                    HttpHeaders headers = new HttpHeaders();
                    headers.add("Authorization", "ApiKey *myApiKey*");
                    return headers;
                })
                .build();
    }
}

```

my config bean is above.

How can i fix this.?

---

<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:** [May 22, 2024, 8:42pm UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024/2 "2024-05-22T20:42:50Z")

</div>

You are connecting the Elasticsearch client to Kibana instead of connecting to Elasticsearch I think.

---

<div class="post-metadata">

**Author:** ![fsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fsk/32/134612_2.png) [@fsk](https://discuss.elastic.co/u/fsk)\
**Post date:** [May 22, 2024, 8:49pm UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024/3 "2024-05-22T20:49:24Z")

</div>

Yess. Sorry.

```auto
    @Override
    @NonNull
    public ClientConfiguration clientConfiguration() {

        return ClientConfiguration.builder()
                .connectedTo("https://a43468016c62e64.westeurope.azure.elastic-cloud.com:92432")
                .withHeaders(() -> {
                    HttpHeaders headers = new HttpHeaders();
                    headers.add("Authorization", "ApiKey **MyApiKey**");
                    return headers;
                })
               .build();
    }

}

```

This is true config. But now,

```auto
Caused by: java.net.UnknownHostException: https://a43468016c62e64.westeurope.azure.elastic-cloud.com:443: nodename nor servname provided, or not known
        at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:52)
        at java.base/java.net.InetAddress$PlatformResolver.lookupByName(InetAddress.java:1211)
        at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1828)
        at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:1139)
        at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1818)
        at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1688)
        at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:666)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:637)
        at org.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:474)
        at org.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:280)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:295)
        at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:381)
        at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:130)
        at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.execute(CloseableHttpAsyncClientBase.java:116)
        at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:138)
        at org.elasticsearch.client.RestClient.performRequest(RestClient.java:300)
        ... 92 more

```

And wnen i try like this without https://

```auto
    @Override
    @NonNull
    public ClientConfiguration clientConfiguration() {

        return ClientConfiguration.builder()
                .connectedTo("a43708ceefac456cb859468016c62e64.westeurope.azure.elastic-cloud.com:9243")
                .withHeaders(() -> {
                    HttpHeaders headers = new HttpHeaders();
                    headers.add("Authorization", "ApiKey o0LY2pgXR0KSqQt2duSeTA");
                    return headers;
                })
                .build();
    }
}

```

Error is same

```auto
Caused by: co.elastic.clients.transport.TransportException: node: http://a43708ceefac456cb859468016c62e64.westeurope.azure.elastic-cloud.com:9243/, status: 400, [es/indices.create] Expecting JSON data but response content-type is: application/octet-stream
        at co.elastic.clients.transport.ElasticsearchTransportBase.checkJsonContentType(ElasticsearchTransportBase.java:471)
        at co.elastic.clients.transport.ElasticsearchTransportBase.getApiResponse(ElasticsearchTransportBase.java:334)
        at co.elastic.clients.transport.ElasticsearchTransportBase.performRequest(ElasticsearchTransportBase.java:147)
        at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.create(ElasticsearchIndicesClient.java:277)
        at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.lambda$doCreate$0(IndicesTemplate.java:145)
        at org.springframework.data.elasticsearch.client.elc.ChildTemplate.execute(ChildTemplate.java:71)
        ... 86 more

```

---

<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:** [May 22, 2024, 11:39pm UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024/4 "2024-05-22T23:39:32Z")

</div>

Go to your cloud console and just copy the Elasticsearch endpoint url. Paste it in your code.

The logs you shared and the code are sometimes inconsistent so I'm not sure about what you're doing exactly.

---

<div class="post-metadata">

**Author:** ![fsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fsk/32/134612_2.png) [@fsk](https://discuss.elastic.co/u/fsk)\
**Post date:** [May 22, 2024, 11:45pm UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024/5 "2024-05-22T23:45:21Z")

</div>

I still run on debug mode.

There is a decompiled class called `ElasticsearchTransportBase.class`

And my related method is below

```auto
    private void checkJsonContentType(
        String contentType, TransportHttpClient.Response clientResp, Endpoint<?, ?, ?> endpoint
    ) throws IOException {
        if (contentType == null) {
            throw new TransportException(clientResp, "Response has no content-type", endpoint.id());
        }

        if (contentType.startsWith("application/json") || contentType.startsWith("application/vnd.elasticsearch+json")) {
            return;
        }

        throw new TransportException(clientResp, "Expecting JSON data but response content-type is: " + contentType, endpoint.id());
    }

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/f/7f423884054a5d216484388b7fe415654f72fc82.jpeg)  
If you inspect this image, ClinetResp object give me error ....

Becouse contentType is come `application/octet-stream` but expected is `application-json`

---

<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:** [May 23, 2024, 1:58am UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024/6 "2024-05-23T01:58:50Z")

</div>

I think it comes with the wrong content type because you are not hitting the right endpoint. I can see in the capture that your are using http and not https.

---

<div class="post-metadata">

**Author:** ![fsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fsk/32/134612_2.png) [@fsk](https://discuss.elastic.co/u/fsk)\
**Post date:** [May 23, 2024, 8:39am UTC](https://discuss.elastic.co/t/node-http-boardoftrustees-elk-kb-westeurope-azure-elastic-cloud-com-9243-status-400-es-indices-create-expecting-json-data-but-response-content-type-is-application-octet-stream/360024/7 "2024-05-23T08:39:59Z")

</div>

I am using withouth https. At the same time, i am not use http. Just [a43708ceefac456cb859468016c62e64.westeurope.azure.elastic-cloud.com:9243](http://a43708ceefac456cb859468016c62e64.westeurope.azure.elastic-cloud.com:9243)

And when i connect to with `https://a43708ceefac456cb859468016c62e64.westeurope.azure.elastic-cloud.com:9243` code give me `nodename nor servname provided or not known` error.
