I updated my code to create a ticket using RT REST 2 API to attach an uploaded file and i got this issue:
{“message”:“JSON parse error: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before “(end of string)”)\n”}
Here is my code:
$headers = array(
“Content-type: application/json”,
“Authorization: token 1-14-c6cde7f274dcbf4f8d1bf2da32449518”
);
$full_path=DIR.’/design-02.png’;
$curlFile = curl_file_create($full_path,mime_content_type($full_path),‘design.png’);
$ticket_data=array(
“Queue” => “General”,
“Subject” => “hello world”,
“Content” => “That damned printer is out of order again!”,
“ContentType”=> “text/html”,
“CustomFields”=>array(‘Phone’=>‘65666’,‘UploadField’=>array(‘fichier1’=>array(‘FileContent’=> file_get_contents($curlFile->getFilename()),‘FileName’=>$curlFile->getPostFilename(),‘FileType’=>$curlFile->getMimeType())))
);
$post = $ticket_data;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$base_url.‘ticket’);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
$result=curl_exec ($ch);
$resp= json_decode($result,true);
curl_close ($ch);
Thanks for the support