0

API Ref: https://developers.freshdesk.com/api/#tickets

I am able to run 'GET' requests without issue, my only issue is with POST. Here is my code:

##Formatting
$FDJType = '"type":'+$FDType
$FDJReqEmail = '"email":'+$FDReqEmail
$FDJSubject = '"subject":'+$FDSubjectwithAutoID
$FDJStatus = '"status":'+$FDStatus
$FDJPriority = '"priority":'+$FDPriority
$FDJDescription = '"description":'+$FDDescription 
$FDJSource = '"source":'+$FDSource

#Prep for Json
$FDJsonpre = [System.Collections.ArrayList]::new()
[void]$FDJsonpre.Add($FDJReqEmail)
[void]$FDJsonpre.Add($FDJStatus)
[void]$FDJsonpre.Add($FDJPriority)
[void]$FDJsonpre.Add($FDJSource)
[void]$FDJsonpre.Add($FDJSubject)
[void]$FDJsonpre.Add($FDJDescription)
[void]$FDJsonpre.Add($FDJType)

#Convert to Json
$FDJson = $FDJsonpre | ConvertTo-Json

#Actual Call
$curl = curl.exe -v -u $FDAPIKey -H "Content-Type: application/json" -d '{$FDJson}' -X POST "$FDTicketsURL"

I get the following error: {"code":"invalid_json","message":"Request body has invalid json format"}

The format is accepted in other JSON formatters, just not in Freshdesk.

Here is the output for reference (slightly modified the email value)

[
"\"email\":\"itsame@mario.com\"",
"\"status\":2",
"\"priority\":1",
"\"source\":1",
"\"subject\":\"Testing the Fresdesk API Post Feature - AutoTask INC123456\"",
"\"description\":\"This is a test post from Freshdesk API\"",
"\"type\":\"Request\""
] 

Any suggestions? Thank you very much!

Technoob1984
  • 172
  • 9

0 Answers0