The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
With the code below attempting to send a zip file to the sis_imports API, I am getting a PowerShell error, "Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send."
$URL = "https://$APIDomain/api/v1/accounts/1/sis_imports"
$headers = @{"Authorization"="Bearer "+$Token}
$InFile = $ZipDestinationFull <# path to zip file #>
$contentType = "application/zip"
Invoke-WebRequest -URI $URL -Headers $headers -Method POST -InFile $InFile -ContentType $contentType
Any idea what I'm missing?
Note, the code seems to work for PowerShell 7, but not PowerShell 5 (the version that my institution uses).
Solved! Go to Solution.
I found a solution. It apparently has to do with a TLS compatability issue.
Source: https://blog.darrenjrobinson.com/powershell-the-underlying-connection-was-closed-an-unexpected-error...
Solution:
Insert the following line before invoking your PowerShell WebRequest using either Invoke-RestMethod or Invoke-WebRequest.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
I found a solution. It apparently has to do with a TLS compatability issue.
Source: https://blog.darrenjrobinson.com/powershell-the-underlying-connection-was-closed-an-unexpected-error...
Solution:
Insert the following line before invoking your PowerShell WebRequest using either Invoke-RestMethod or Invoke-WebRequest.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in