# Curl XPOST not working after upgrading from Elastic v7 to Elastic v8

**URL:** https://discuss.elastic.co/t/curl-xpost-not-working-after-upgrading-from-elastic-v7-to-elastic-v8/350706
**Category:** Elasticsearch
**Created:** [January 10, 2024, 8:01am UTC](https://discuss.elastic.co/t/curl-xpost-not-working-after-upgrading-from-elastic-v7-to-elastic-v8/350706 "2024-01-10T08:01:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![zeninuxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeninuxx/32/130661_2.png) [@zeninuxx](https://discuss.elastic.co/u/zeninuxx)
#### Post date: [January 10, 2024, 8:01am UTC](https://discuss.elastic.co/t/curl-xpost-not-working-after-upgrading-from-elastic-v7-to-elastic-v8/350706/1 "2024-01-10T08:01:27Z")

</div>

This is an example of a json file I am trying to POST into elasticsearch:

```auto
{"index": {}}
{"topic": "example1", "size": 2192, "timestamp": "2024-01-10"}
{"index": {}}
{"topic": "example2", "size": 2052, "timestamp": "2024-01-10"}
{"index": {}}
{"topic": "example3", "size": 1405, "timestamp": "2024-01-10"}
{"index": {}}
{"topic": "example4", "size": 1164, "timestamp": "2024-01-10"}

```

This is the command I was using when I was still in elastic v7 (and it was working):

```auto
curl -vvv -sk -u "test:password" -XPOST "https://<url>/acc-index-storage-sizes/_doc/_bulk?pretty" -H 'Content-Type: application/json' --data-binary "@outfile.json"

```

When I migrated to v8, I had to update my command to:

```auto
curl -s -k -H "Authorization: ApiKey $ApiKey" -XPOST "https://<api url>/acc-index-storage-sizes/_doc/_bulk?pretty" -H 'Content-Type: application/json' --data-binary "@outfile.json"

```

However, I keep on encountering this error:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Malformed content, found extra data after parsing: START_OBJECT"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Malformed content, found extra data after parsing: START_OBJECT"
  },
  "status" : 400
}

```

Anyone familiar with this? I tried looking for documentations and it said to put \_bulk but I already included it in the POST command.

---

<div class="post-metadata">

### Author: ![yago82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yago82/32/97755_2.png) [@yago82](https://discuss.elastic.co/u/yago82)
#### Post date: [January 10, 2024, 9:26am UTC](https://discuss.elastic.co/t/curl-xpost-not-working-after-upgrading-from-elastic-v7-to-elastic-v8/350706/2 "2024-01-10T09:26:33Z")

</div>

> [@zeninuxx](#):
>
> {"index": {}}  
> {"topic": "example1", "size": 2192, "timestamp": "2024-01-10"}  
> {"index": {}}  
> {"topic": "example2", "size": 2052, "timestamp": "2024-01-10"}  
> {"index": {}}  
> {"topic": "example3", "size": 1405, "timestamp": "2024-01-10"}  
> {"index": {}}  
> {"topic": "example4", "size": 1164, "timestamp": "2024-01-10"}

Hi,

Try to validate your JSON file using a JSON validator tool. This can help you identify any syntax errors or formatting issues in your JSON file.

[JSON Online Validator and Formatter - JSON Lint](https://jsonlint.com/)

Regards

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 10, 2024, 9:46am UTC](https://discuss.elastic.co/t/curl-xpost-not-working-after-upgrading-from-elastic-v7-to-elastic-v8/350706/3 "2024-01-10T09:46:25Z")

</div>

One thing that has changed between v7 and v8 is that document types now are deprecated, although I think you can configure it to use compatibility mode.

What happens if you remove the document type (`_doc`) and try the following:

`curl -s -k -H "Authorization: ApiKey $ApiKey" -XPOST "https:///acc-index-storage-sizes/_bulk?pretty" -H 'Content-Type: application/json' --data-binary "@outfile.json"`

---

<div class="post-metadata">

### Author: ![zeninuxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeninuxx/32/130661_2.png) [@zeninuxx](https://discuss.elastic.co/u/zeninuxx)
#### Post date: [January 12, 2024, 8:51am UTC](https://discuss.elastic.co/t/curl-xpost-not-working-after-upgrading-from-elastic-v7-to-elastic-v8/350706/4 "2024-01-12T08:51:00Z")

</div>

Hi, I tried validating it but it failed. However, what boggles my mind is that there was no problem with the format when I was using to to XPOST to elastic v7, the POST was successful every time. For elastic v8, I'm still using the same exact format yet it fails.

---

<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: [February 9, 2024, 8:51am UTC](https://discuss.elastic.co/t/curl-xpost-not-working-after-upgrading-from-elastic-v7-to-elastic-v8/350706/5 "2024-02-09T08:51:27Z")

</div>

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