Elasticsearch bulk index request failing with error “if _id is specified it must not be empty”

I am trying to bulk insert records to index asset_inventory_dev index. Elastic search is returning error saying “if _id is specified it must not be empty”.

Following is the request i tried from Kibana dev tools. I can see the _id fields are having some valid values.

Elasticstack version: v 7.10.1

POST /asset_inventory_dev/_bulk
    {"index":{"_index":"asset_inventory_dev","_id":"62"}}
    {"@timestamp":"2021-01-11T09:41:01.26+00:00","_id":"62","computer_id":"1065816795","computer_name":"PC123475367"}

Response:

 {
      "took" : 0,
      "ingest_took" : 0,
      "errors" : true,
      "items" : [
        {
          "index" : {
            "_index" : "asset_inventory_dev",
            "_type" : "_doc",
            "_id" : "",
            "status" : 400,
            "error" : {
              "type" : "illegal_argument_exception",
              "reason" : "if _id is specified it must not be empty"
            }
          }
        }
      ]
    }

What is that i am missing in the above request?

You have _id defined twice, I would remove the second one.

I tried removing the second _id field but error persists.

POST _bulk

{"index":{"_index":"asset_inventory_dev","_id":"62"}}
{"@timestamp":"2021-01-11T09:41:01.26+00:00","computer_id":"1065816795","computer_name":"PC123475367"}

Response:

{
  "took" : 0,
  "ingest_took" : 0,
  "errors" : true,
  "items" : [
    {
      "index" : {
        "_index" : "asset_inventory_dev",
        "_type" : "_doc",
        "_id" : "",
        "status" : 400,
        "error" : {
          "type" : "illegal_argument_exception",
          "reason" : "if _id is specified it must not be empty"
        }
      }
    }
  ]
}

I just tried that exact same thing on a 7.10.1 cluster;

{
  "took" : 143,
  "errors" : false,
  "items" : [
    {
      "index" : {
        "_index" : "asset_inventory_dev",
        "_type" : "_doc",
        "_id" : "62",
        "_version" : 1,
        "result" : "created",
        "_shards" : {
          "total" : 2,
          "successful" : 1,
          "failed" : 0
        },
        "_seq_no" : 0,
        "_primary_term" : 1,
        "status" : 201
      }
    }
  ]
}

What version are you on?