Invoke-RestMethod: The underlying connection was closed: An unexpected error occurred on a send

%3CLINGO-SUB%20id%3D%22lingo-sub-2678070%22%20slang%3D%22en-US%22%3EInvoke-RestMethod%3A%20The%20underlying%20connection%20was%20closed%3A%20An%20unexpected%20error%20occurred%20on%20a%20send%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2678070%22%20slang%3D%22en-US%22%3E%3CP%3EWhile%20trying%20to%20use%20the%26nbsp%3BInvoke-RestMethod%2C%20I%20am%20getting%3A%20The%20underlying%20connection%20was%20closed%3A%20An%20unexpected%20error%20occurred%20on%20a%20send.%3C%2FP%3E%3CP%3EI%20tried%20using%26nbsp%3B%5BNet.ServicePointManager%5D%3A%3ASecurityProtocol%20%3D%20%5BNet.SecurityProtocolType%5D%3A%3ATls%20-bor%20%5BNet.SecurityProtocolType%5D%3A%3ATls11%20-bor%20%5BNet.SecurityProtocolType%5D%3A%3ATls12%20before%20Invoke-RestMethod.%3C%2FP%3E%3CP%3EBut%2C%20after%20adding%20this%20before%20Invoke-RestMethod%20I%20am%20getting%20RPC%20server%20is%20unavailable.%3C%2FP%3E%3CP%3EAny%20solution%20to%20this%20please%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2678070%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

While trying to use the Invoke-RestMethod, I am getting: The underlying connection was closed: An unexpected error occurred on a send.

I tried using [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12 before Invoke-RestMethod.

But, after adding this before Invoke-RestMethod I am getting RPC server is unavailable.

Any solution to this please?

0 Replies