【发布时间】:2019-12-03 22:25:20
【问题描述】:
我正在尝试调用使用 Invoke_RestMethod 调用的 powershell 脚本。 powershell 脚本在同事的计算机上按原样工作,但在我的计算机上却没有,这完全一样。我收到以下错误
15:47:48.270 Invoke-RestMethod : Not Found
15:47:48.271 At C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCI\Client\deliver.ps1:15 char:1
15:47:48.272 + Invoke-RestMethod -Body $body -Method 'Post' -Uri $url
这是我调用的名为 delver.ps1 的 powershell 脚本
$url = 'https://pulse-us-east-1.qtestnet.com/webhook/b9303bb6-d0e1-43ce-bf96be4a3b330c8f'
Set-Location -Path "C:\Tosca_Projects\Tosca_Workspaces\First Steps\Test Results"
$payload = (Get-Content "result.xml" -Raw)
$body = @{
'projectId' = '95814'
'test-cycle' = '3539385'
'requiresDecode' = 'true'
'result' = $payload
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-RestMethod -Body $body -Method 'Post' -Uri $url
我运行的是 Windows 10 Powershell 版本 5.1.17763.503,我什至升级到了 powershell 6.2.3,我得到了同样的错误
【问题讨论】:
-
您是否尝试过使用
https://postman-echo.com/post来验证它是否适用于返回响应的 URL?我怀疑“未找到”是返回 404 响应的消息。 -
格伦,这很有效,非常有趣......
标签: powershell powershell-core