# BulkIngester: Received \`not\_x\_content\_exception\` when adding json

**URL:** <https://discuss.elastic.co/t/bulkingester-received-not-x-content-exception-when-adding-json/329812>\
**Category:** Elasticsearch\
**Created:** [April 12, 2023, 8:34am UTC](https://discuss.elastic.co/t/bulkingester-received-not-x-content-exception-when-adding-json/329812 "2023-04-12T08:34:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ALX\_DM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alx_dm/32/106314_2.png) [@ALX\_DM](https://discuss.elastic.co/u/ALX_DM)\
**Post date:** [April 12, 2023, 8:34am UTC](https://discuss.elastic.co/t/bulkingester-received-not-x-content-exception-when-adding-json/329812/1 "2023-04-12T08:34:09Z")

</div>

In the new BulkIngester, how to add json data?

I have this json:

```auto
{
  "time": "2023-04-13T02:44:16.1782763Z",
  "user_id": 1,
  "user_name": "admin",
  "host_name": "localhost:5567",
  "type": "PRODUCT_DELETE",
  "long_asset_id": 9,
  "long_parent_asset_id": 1,
  "path_path": "C:\\datastores\\ds1\\beats_2021+Logo.jpg"
}

```

I add this to BulkIngester but I get `not_x_content_exception`

This is how I do it:

```auto
 private final BulkIngester<String> bulkIngester = BulkIngester.of(
      b ->
        b.client(esClient)
          .maxOperations(100)
          .flushInterval(flushInterval, TimeUnit.SECONDS)
          .listener(listener);

String jsonPayload = objectMapper.writeValueAsString(
    new MyObject("2023-04-13T02:44:16.1782763Z", 1, "admin", "localhost:5567", "PRODUCT_DELETE", 9, 1, "C:\\datastores\\ds1\\beats_2021+Logo.jpg")

 bulkIngester.add(b-> b.index(idx -> idx.index("product_index").document(jsonPayload )));
);

```

I receive this error:

```auto
BulkResponseItem: {
  "index": {
    "_id": "hsSndIcB_urHloQdKovN",
    "_index": "product_index",
    "status": 400,
    "error": {
      "type": "mapper_parsing_exception",
      "reason": "failed to parse",
      "caused_by": {
        "type": "not_x_content_exception",
        "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
      }
    },
    "_type": "_doc"
  }
}

```

No idea why is this happening.  
In old BulkProcessor, this works, but when I migrate to new BulkIngester, it fails.

Any ideas is greatly appreciated.

---

<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 10, 2023, 8:46am UTC](https://discuss.elastic.co/t/bulkingester-received-not-x-content-exception-when-adding-json/329812/3 "2023-05-10T08:46:15Z")

</div>

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