没有从Invoke-RestMethod得到任何错误或响应

时间:2018-10-17 08:34:53

标签: powershell

我尝试在PowerShell脚本中调用rest API,但是我完全没有得到任何错误或响应。

try { 
    $result = Invoke-RestMethod -Uri $uri -Method Put -Body $body -ContentType "application/json" -Headers $Headers  -TimeoutSec 10  -Verbose -ErrorAction Stop

    "Result:"    
    Write-Host $result
} catch {
    $_.Exception  
    Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
    Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription

}

输出就是

PS C:\temp> .\PutJSON.ps1
VERBOSE: PUT http://111.1.1.11:2345/a/rest/test with -1-byte payload
VERBOSE: received -1-byte response of content type
Result:


PS C:\temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.228

我想知道为什么我至少没有得到任何错误。任何帮助都会很棒!

0 个答案:

没有答案