Hello ,
we want to add a note to an existing ticket via PHP and the FD API (code below).
This works so far so good, but we also want to change the status of the ticket.
But if I add the status filed to the request I get:
{“description”:“Validation failed”,“errors”:[{“field”:“status”,“message”:“Unexpected/invalid field in request”,“code”:“invalid_field”}]}
Any ideas?
Regards
Kalle
function FreshDeskAddTicketNote ($ticketID,$content)
{
global $__apiKey;
global $__password;
global $__fdDomain;
$ret=false;
$ticket_data = json_encode(array(
"body" => $content,
"incoming" => false,
"private" => true,
"status" => 2,
));
$url = https://$__fdDomain.freshdesk.com/api/v2/tickets/$ticketID/notes;
$ch = curl_init($url);
$header[] = "Content-type: application/json";
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$__apiKey:$__password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $ticket_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$info = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);
$code=$info['http_code'];
if($code == 200 || $code == 201) {
$ret=true;
}
else
{
echo ("<br>code: $code");
echo "Response Headers are \n";
echo $headers."\n";
echo "Response Body \n";
echo "$response \n";
}
curl_close($ch);
return $ret;
}