小编Jus*_*win的帖子

调用 RestMethod 错误:无法发送正文类型

我正在尝试使用 Invoke-RestMethod 从 Freshdesk 获取门票。我收到的错误是“Invoke-RestMethod:无法发送具有此动词类型的内容正文”。我的函数如下所示:

function opentickets()
{
$Body = @{
#description = $description.Text
email = $email.Text
#subject = $subject.Text
#type = $request.Text
#priority = 1
#status = 2
}
Invoke-RestMethod -uri "https://clasd.freshdesk.com/api/v2/tickets?" - 
ContentType application/json -Method Get -Body ($Body | ConvertTo-Json)
}
Run Code Online (Sandbox Code Playgroud)

用于查看票证的 Freshdesk API 端点应返回类似于 freshdesk 使用curl 提供的示例的内容:

https://clasd.freshdesk.com/api/v2/tickets?email=[requester_email]

更新 如果我使用以下内容:

Invoke-RestMethod -uri 
"https://clasd.freshdesk.com/api/v2/tickets? 
email=xyz@clasd.net" -Headers $FDHeaders -ContentType 
 application/json -Method Get 
Run Code Online (Sandbox Code Playgroud)

我收到了想要的结果。我可以将 Invoke 命令的结果输出为用户更易读的内容吗?

powershell powershell-2.0 powershell-3.0 powershell-4.0 freshdesk

2
推荐指数
1
解决办法
2万
查看次数