title: Invoke-RestMethod: You must write ContentLength bytes to the request stream
body: <p>I am trying to upload a file to a URL. I have tried both these approaches:</p>
  
  <pre><code>Invoke-RestMethod -Uri $uploadUrl -Method Put -Headers $uploadHdrs -InFile $uploadFilePath
  
  Invoke-RestMethod -Uri $uploadUrl -Method Put -body $uploadFileBody -Headers $uploadHdrs
  </code></pre>
  
  <p>Error I am getting:</p>
  
  <pre><code>Invoke-RestMethod : You must write ContentLength bytes to the request stream
  before calling [Begin]GetResponse.
  </code></pre>
  
  <p>If I add in the <code>-TransferEncoding</code> param, I get errors from the server saying unsupported.</p>
  
  <p>What can I do to include the content length?</p>