title: Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send. - jenkins
body: <p>Hi I have an issue with my jenkins invoke command via pshell when I try to run: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$restoreSecProto = [Net.ServicePointManager]::SecurityProtocol
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  $base64 = [System.Convert]::ToBase64String(([System.Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $cred.Username, $cred.GetNetworkCredential().Password))))
  $basicAuthValue = "Basic $base64"
  $headers = @{ 'Authorization' = $basicAuthValue }
  
  $crumb = Invoke-RestMethod -Headers $headers -Uri 'https://localhost:8443/crumbIssuer/api/xml?xpath=//crumb' -SessionVariable session -UseBasicParsing 
  $session
  $headers.Add('Jenkins-Crumb', $crumb.crumb) </code></pre>
  </div>
  </div>
  </p>
  
  <p>error: 
  Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.</p>
  
  <p>please note that CSRF is enabled</p>
  
  <p>thanks for help</p>