I am trying to GET tickets from Freshdesk using the Invoke-RestMethod. The error I'm receiving is "Invoke-RestMethod: Cannot send a content-body with this verb type". My function looks like this:
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)
}
The Freshdesk API endpoint to view tickets should return something like the examples that freshdesk gives using curl:
https://clasd.freshdesk.com/api/v2/tickets?email=[requester_email]
Update If I use the following:
Invoke-RestMethod -uri
"https://clasd.freshdesk.com/api/v2/tickets?
email=xyz@clasd.net" -Headers $FDHeaders -ContentType
application/json -Method Get
I receive the desired outcome. Can I output the result from the Invoke command to something more readable for a user?