title: Post PowerShell JSON into ElasticSearch
body: <p>I'm trying to push some data into ElasticSearch via PowerShell. I'm converting the data into JSON, then trying both <code>Invoke-WebRequest</code> and <code>Invoke-RestMethod</code>, but always get errors on malformed data or content-type not supported. I haven't created the index as I believe it will create it for me.</p>
  
  <p>Anyone able to assist on what I'm missing/doing wrong?</p>
  
  <p>Example code:</p>
  
  <pre><code>$data = @()
  $CustomObject = [pscustomobject]@{
          SqlInstance = "myserver1"
          Database = "mydb"
          Schema = "versioning"
          Name = "DataVersionHistory"
          IndexSpaceUsed = 0
          DataSpaceUsed = 0
          RowCount = 0
          };
  $data += $CustomObject;
  $CustomObject = [pscustomobject]@{
          SqlInstance = "myserver1"
          Database = "mydb"
          Schema = "versioning"
          Name = "VersionHistory"
          IndexSpaceUsed = 10
          DataSpaceUsed = 25
          RowCount = 3000
          };
  $data += $CustomObject;
  $myJson = ConvertTo-Json -InputObject $data ;
  Invoke-RestMethod -Uri http://localhost:9200/myindex/mytype/_bulk?pretty `
  -Method POST -Body $myJson -ContentType "application/json"
  </code></pre>