title: Convert Curl to Invoke-RestMethod
body: <h1>Problem</h1>
  <p>I am having a hard time converting a <strong>curl</strong> call into a Powershell <strong>Invoke-RestMethod</strong> call as Powershell doesn't really thow the most informative error messages (if any).</p>
  <h1>Curl call (Ubuntu)</h1>
  <pre><code>token = &quot;djsakldsakldjaslda&quot;
  host = &quot;https://lalala.azuredatabricks.net/&quot;
  curl -X POST -H &quot;Authorization: Bearer $(token)&quot; $(host)/api/2.0/clusters/create -d $(cat my_file.json)
  </code></pre>
  <h1>Invoke-RestMethod call (Powershell)</h1>
  <pre><code>$token= &quot;djsakldsakldjaslda&quot;
  $host = &quot;https://lalala.azuredatabricks.net/&quot;
  Invoke-RestMethod -Method Post -Uri $host/api/2.0/clusters/create -Headers @{&quot;Authorization&quot; = &quot;Bearer &quot; + $token} -Body $(get-content my_file.json -raw | ConvertFrom-Json)
  </code></pre>
  <p>I have various formats for the body, but no matter what I send, I just get some HTML back for a login page. On Ubuntu with Curl everything works perfectly.</p>
  <p>NOTE:<br />
  The problem seemed to be that PowerShell cannot handle double-&quot;/&quot; as in &quot;https://lalala.azuredatabricks.net//api/2.0/clusters/create&quot;.</p>
  <p>The strange part is that <strong>Invoke-RestMethod</strong> gets to the login page, but fails from there.</p>