POST to elasticsearch bulk api from powershell

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 += "rn"
$postParams += (@{ ""=; ""=; ""=} | convertto-json -compress)
$postParams += "rn"

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


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