我正在尝试使用 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)
}
用于查看票证的 Freshdesk API 端点应返回类似于 freshdesk 使用curl 提供的示例的内容:
https://clasd.freshdesk.com/api/v2/tickets?email=[requester_email] https://clasd.freshdesk.com/api/v2/tickets?email=%5Brequester_email%5D
Update如果我使用以下内容:
Invoke-RestMethod -uri
"https://clasd.freshdesk.com/api/v2/tickets?
[email protected] /cdn-cgi/l/email-protection" -Headers $FDHeaders -ContentType
application/json -Method Get
我收到了想要的结果。我可以将 Invoke 命令的结果输出为用户更易读的内容吗?
对于任何客户端,您都无法将带有 GET 请求的负载(正文)发送到 RESTful 服务。过去,大多数客户都允许您这样做,但现在已经改变了。
您的解决方法有助于通过使用查询字符串来修复该问题。您必须查看 Freshdesk 的文档,了解它们是否支持用于检索票证信息的 POST 请求,或者确保查询字符串方法能够满足您的需求。
看起来建议通过查询方法过滤票证:
https://developers.freshdesk.com/api/#filter_tickets https://developers.freshdesk.com/api/#filter_tickets
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)