我在PowerShell上运行Invoke-RestMethod来调用Web API方法。它可以工作,但大约一分钟后,我得到一个超时错误。我真的希望PowerShell能等到被调用的方法完成。我该怎么做呢?谢谢你的帮助。约翰
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发布于 2014-11-19 17:32:32
根据Technet documentation for the Invoke-RestMethod cmdlet的说法,有一个超时参数可以附加到调用中。默认设置为不确定,但有用户抱怨默认设置为100秒。
我看不到您的所有代码,但是,要指定2分钟的超时,您的调用应该如下所示:
Invoke-RestMethod -Uri "http://corloclaf2/api/Automation/GetAutomation?test" -TimeoutSec 120https://stackoverflow.com/questions/26993943
复制相似问题