Timeout Error When Invoke-RestMethod Launched

I run Invoke-RestMethod in PowerShell to call the Web API method. It works, but after a minute or so I get a timeout error. I would really like PowerShell to wait for the processed method to complete. How can I do it? Thanks for any help. John

PS C:\Test\TestScripts> .\Run_Automation 5.5.4.382.1 VERBOSE: GET http://server/api/Automation/GetAutomation?testName=5.5.4.382.1 with 0-byte payload Invoke-RestMethod : The operation has timed out. At C:\TeamCity\TeamCityScripts\Run_Automation.ps1:20 char:5 + Invoke-RestMethod -Uri http://corloclaf2/api/Automation/GetAutomation?testNa ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId :WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand 
+6
source share
1 answer

According to the Technical Documentation for the Invoke-RestMethod cmdlet , there is a timeout argument that you can add to your call. It is assumed that it is undefined by default, but there is a user complaining that by default it is 100 seconds.

I do not see all your code, but to indicate a timeout of 2 minutes, your call should look like this:

 Invoke-RestMethod -Uri "http://corloclaf2/api/Automation/GetAutomation?test" -TimeoutSec 120 
+9
source

Source: https://habr.com/ru/post/978326/


All Articles