title: cUrl vs Invoke-WebRequest
body: <p>Can anybody explain to me why <code>cUrl</code> (the real cUrl) works but <code>Invoke-WebRequest</code> doesn’t? Same machine, same variables. To me it looks like they should both be doing the same thing, uploading a file to jfrog Artifactory.</p>
  
  <pre><code>$headers = @{
    'X-JFrog-Art-Api' = $apiKey
    "Content-Type" = "application/json"
    "Accept" = "application/json"
  }
  
  Invoke-WebRequest -InFile $file -Method Put -Uri "$ARTIFACTORY_HOST/third-party/test/readme.md" -Headers $headers -Verbose
  </code></pre>
  
  <p>This PowerShell doesn't work.</p>
  
  <pre><code>curl -T readme.md "${ARTIFACTORY_HOST}/third-party/test/readme.md " \
  -H "X-JFrog-Art-Api: ${apiKey}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json"
  </code></pre>
  
  <p>cUrl works.</p>
  
  <p>PowerShell fails with </p>
  
  <pre><code>Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
  At line:1 char:1
  + Invoke-WebRequest -InFile $file -Method Put -Uri "https:// ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
  </code></pre>