0

I want to pass body(parameters) to Rest-call using Invoke-RestMethod(powershell script) in GET call. but I think it's not supported because of some security reasons(some RFC standards).

But in single session, When I first use POST method and then if I use GET method then it works. but if I directly call get method then it's throwing below error.

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

So, Is there some information powershell stores after first call ? Also, Is there any way to pass parameters to "GET" Restcall in powershell script ?

I've attached code snippet: this snippet is working.

Invoke-RestMethod 'https://test_url/url_path?param1=par' -Method 'POST' -Headers $headers

Invoke-RestMethod 'https://test_url/url_path?param1=par' -Method 'GET' -Headers $headers  # works

but this throws the error,

Invoke-RestMethod 'https://test_url/url_path?param1=par' -Method 'GET' -Headers $headers #Not works
Manan
  • 1
  • perhaps this might help https://blog.darrenjrobinson.com/powershell-the-underlying-connection-was-closed-an-unexpected-error-occurred-on-a-send/ – codebrane Nov 24 '20 at 14:12
  • @codebrane I tried same thing mentioned in blog, still getting same error. Do you know any other lib/way by which we can call get method with parameters in powershell script? – Manan Nov 26 '20 at 08:04

0 Answers0