title: Invoke-RestMethod convert hashtable to json array
body: <p>I'm trying to send a request to an API that requires the body to be a json array. How can I convert the parameters hash table into a json array?</p>
  
  <pre><code>$parameters =@{
  
                  "sn" = "CND3210W9M"
                  "pn" = "D5H49AV"
            }
   $post = Invoke-RestMethod -Uri "https://blah.com/queries" -Method Post -Body ($parameters | ConvertTo-Json) -Headers $headers -ContentType 'application/json'
  </code></pre>
  
  <p>The API example shows the array below as a valid body</p>
  
  <pre><code> [
     {
       "sn": "CND3210W9M",
       "pn": "D5H49AV"
     }
   ]
  </code></pre>