Attachment via API

  • 12 December 2014
  • 2 replies
  • 106 views

Hi.


I want to send an attachment file via API, but I get error "500". We search in API documentation, technical support, and nothing.


This is the example code found in Github :

$jsondata = array (
'helpdesk_ticket[email]' => 'john@freshdesk.com',
'helpdesk_ticket[subject]' => 'test',
'helpdesk_ticket[description]' => 'testing description content',
'helpdesk_ticket[attachments][][resource]' => "@" . "/Users/johnpaul/Examples/tommy1.jpg"
);
$header[] = "Content-type: multipart/form-data";

But when I tried this always to my own URL (i.e. $url = 'http://yourcompany.freshdesk.com/helpdesk/tickets.json') the error is 500.



This topic has been closed for comments

2 replies

I believe you are using this example: https://github.com/freshdesk/fresh-samples/blob/master/php_samples/add_note_with_attachemnt.php I will shortly verify this example, and update this forum.


Can you also let me know the version of PHP you are using?


I verified the example with PHP 5.5.14, and it works as expected.

Can you add this option to enable debug logging to PHP CURL:

curl_setopt($ch, CURLOPT_VERBOSE, true);

This might give you a hint on what is going wrong.