# ransportException: Expecting JSON data but response content-type is application/octet-stream (Elastic Cloud 8.12)

**URL:** <https://discuss.elastic.co/t/ransportexception-expecting-json-data-but-response-content-type-is-application-octet-stream-elastic-cloud-8-12/375323>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [March 3, 2025, 6:26pm UTC](https://discuss.elastic.co/t/ransportexception-expecting-json-data-but-response-content-type-is-application-octet-stream-elastic-cloud-8-12/375323 "2025-03-03T18:26:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![r3b1135h5](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@r3b1135h5](https://discuss.elastic.co/u/r3b1135h5)\
**Post date:** [March 3, 2025, 6:26pm UTC](https://discuss.elastic.co/t/ransportexception-expecting-json-data-but-response-content-type-is-application-octet-stream-elastic-cloud-8-12/375323/1 "2025-03-03T18:26:31Z")

</div>

Hello,

I'm encountering a `co.elastic.clients.transport.TransportException` with the following error message:

`co.elastic.clients.transport.TransportException: node: http://my-elasticsearch-project-c2b746.es.ap-southeast-1.aws.elastic.cloud:443/, status: 400, [es/index] Expecting JSON data but response content-type is: application/octet-stream`

**Environment Details:**

- Elasticsearch Java Client Version: 8.12
- Spring Data Elasticsearch Version: 4.3.3
- Elasticsearch Server Version (AWS Elastic Cloud): I am using the default version of Elastic Cloud.
- Elasticsearch Cloud TLS enabled: I am using the default Elastic cloud configuration.
- Network Environment: I am using the default Elastic cloud configuration.

**Configuration:**

My Elasticsearch configuration is as follows:

```auto
@Configuration
class ElasticSearchConfig(
    @Value("\${elasticsearch.api}") private val elasticsearchApiKey: String,
    @Value("\${elasticsearch.url}") private val elasticsearchUrl: String,
) : ReactiveElasticsearchConfiguration() {
    override fun clientConfiguration(): ClientConfiguration {
        val client = ClientConfiguration.create(elasticsearchUrl).apply {
            defaultHeaders.add(HttpHeaders.AUTHORIZATION, "ApiKey $elasticsearchApiKey")
        }
        return client
    }
}

```

My `application.properties` file contains:

```auto
elasticsearch.url=my-elasticsearch-project-c2b746.es.ap-southeast-1.aws.elastic.cloud:443

```

**Problem:**

- I'm receiving a 400 error with the `application/octet-stream` content type when attempting to index data.
- If I change `elasticsearch.url` to `https://my-elasticsearch-project-c2b746.es.ap-southeast-1.aws.elastic.cloud:443`, I receive a `nodename nor servname provided or not known` error.
- I have already reviewed this previous discussion, but it did not provide a resolution: [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 - #6 by dadoonet](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)

Indexing Code

```auto
elasticsearchClient.index { it.index("product").document(product) }.id()

```

Index Mapping

```auto
@Document(indexName = "product", createIndex = true)
@Setting(settingPath = "settings.json")
data class Product(
    @Field(type = FieldType.Keyword) var name: String,
    @Field(type = FieldType.Text, analyzer = "synonym_analyzer") val description: String,
    @Field(type = FieldType.Keyword) var categories: List<String> = listOf(),
    @Field(type = FieldType.Keyword) var tags: List<String> = listOf(),
)

```

Could anyone provide insight into why I'm receiving this `application/octet-stream` error and how to resolve it?

Thank you for your assistance.

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [March 4, 2025, 8:22am UTC](https://discuss.elastic.co/t/ransportexception-expecting-json-data-but-response-content-type-is-application-octet-stream-elastic-cloud-8-12/375323/2 "2025-03-04T08:22:23Z")

</div>

Hello and welcome!  
Considering I'm not familiar with Spring Data, I think it's unlikely that an endpoint such as `index` is returning non json data, so my best bet here is that the url used to connect to the elasticsearch instance is wrong, and it's returning some non json error that the client cannot parse. Could you make sure you're using the correct url? You can try following [the AWS guide](https://www.elastic.co/blog/getting-started-with-elastic-cloud-on-amazon-web-services-aws), and if there's nothing new there then there's a [similar solved discussion](https://discuss.elastic.co/t/simple-wheres-the-url-to-query-elastic-cloud-instance/338318).
