# I am trying to create index and upload data in elasticsearch using curl

**URL:** <https://discuss.elastic.co/t/i-am-trying-to-create-index-and-upload-data-in-elasticsearch-using-curl/188213>\
**Category:** Elasticsearch\
**Created:** [July 1, 2019, 12:51am UTC](https://discuss.elastic.co/t/i-am-trying-to-create-index-and-upload-data-in-elasticsearch-using-curl/188213 "2019-07-01T00:51:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SalOomeii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saloomeii/32/48881_2.png) [@SalOomeii](https://discuss.elastic.co/u/SalOomeii)\
**Post date:** [July 1, 2019, 12:51am UTC](https://discuss.elastic.co/t/i-am-trying-to-create-index-and-upload-data-in-elasticsearch-using-curl/188213/1 "2019-07-01T00:51:43Z")

</div>

Hello everyone !  
I am trying to create new index with those data in Elasticsearch  
I have big data in json format I save it in a file  
named  
weather\_to\_json.json

and then I use

this curl

$ curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/\_bulk --data-binary @weather\_to\_json.json

and I find this error

{''error'':{''root\_cause'':[{''type'':''parse\_exception'',''reason'':''request body is required''}],''type'':''''parse\_exception'',''reason'':''request body is required''}, ''status'',:400

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 1, 2019, 9:17am UTC](https://discuss.elastic.co/t/i-am-trying-to-create-index-and-upload-data-in-elasticsearch-using-curl/188213/2 "2019-07-01T09:17:12Z")

</div>

hey,

let's start small and reuse the same example as shown [in the docs](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/docs-bulk.html) - just a single example with two lines.

Does this work?

Also, does the last line contain a newline in your custom file?

--Alex

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [July 1, 2019, 10:47am UTC](https://discuss.elastic.co/t/i-am-trying-to-create-index-and-upload-data-in-elasticsearch-using-curl/188213/3 "2019-07-01T10:47:03Z")

</div>

> [@SalOomeii](#):
>
> {''error'':{''root\_cause'':[{''type'':''parse\_exception'',''reason'':''request body is required''}],''type'':''''parse\_exception'',''reason'':''request body is required''},

I get that error if the json file doesn't exist in the directory where I run the curl command or if I've misspelled the filename, so you may want to verify that you're in the same directory and that the filename is correctly spelled.

---

<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:** [July 29, 2019, 10:47am UTC](https://discuss.elastic.co/t/i-am-trying-to-create-index-and-upload-data-in-elasticsearch-using-curl/188213/4 "2019-07-29T10:47:03Z")

</div>

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