Codebase API Documentation

PHP - Upload a Ticket Attachment

The following code will upload a file to a ticket as a new attachment

$file_to_upload = array( 
  'ticket_attachment[attachment]'=>'@/path/to/file_to_upload.file', 
  'ticket_attachment[description]' => 'test description' 
);

$headers = array(); 
$headers[] = "Authorization: Basic " . base64_encode('test/dan:api_key');

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,"http://api3.codebasehq.com/test-project/tickets/5/attachments";); 
curl_setopt($ch, CURLOPT_POST,TRUE); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $file_to_upload ) ; 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
$result=curl_exec ($ch); 
curl_close ($ch);