# POST to elasticsearch bulk api from powershell

**URL:** <https://discuss.elastic.co/t/post-to-elasticsearch-bulk-api-from-powershell/89541>\
**Category:** Elasticsearch\
**Created:** [June 15, 2017, 11:19am UTC](https://discuss.elastic.co/t/post-to-elasticsearch-bulk-api-from-powershell/89541 "2017-06-15T11:19:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pemby](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@pemby](https://discuss.elastic.co/u/pemby)\
**Post date:** [June 15, 2017, 11:19am UTC](https://discuss.elastic.co/t/post-to-elasticsearch-bulk-api-from-powershell/89541/1 "2017-06-15T11:19:36Z")

</div>

I spent a bit of time stuffing around to get this format right so here it is for anyone else wanting to do this.  
the key was to force the line feed and this was not obvious until i looked at the string in tcpdump.  
Be careful, this web page seems to of removed the left quote (the key on the left of the number 1) from in fron tof the r and the n

$postParams= @()  
$postParams += '{"index":{}}'  
$postParams += "`r`n"  
$postParams += (@{ ""=; ""=; ""=} | convertto-json -compress)  
$postParams += "`r`n"

Invoke-Webrequest -Uri :9200/,Index\>/\<type/\_bulk -Method POST -ContentType "application/x-ndjson " -body $postParams -UseBasicParsing

---

<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 13, 2017, 11:19am UTC](https://discuss.elastic.co/t/post-to-elasticsearch-bulk-api-from-powershell/89541/2 "2017-07-13T11:19:43Z")

</div>

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