ADD_ATTACHMENT api request not working

ADD_ATTACHMENT api request not working

Hi,

I'm trying to add an attachment to a support ticket already created. Please see my code below.

This is written in PHP and therefore I'm finding it difficult to understand the sample code given in documentation.

<?php
$fields = array('filename' => 'test_file.pdf;type=application/pdf');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ' http://servicedesk/sdpapi/request/ticketid/attachment?OPERATION_NAME=ADD_ATTACHMENT&TECHNICIAN_KEY=MY TECHNICIAN KEY');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);

print_r($response);
?>

The error message I'm getting is "Error when adding attachment, the request was rejected because no multipart boundary was found"

Please let me know how this can be corrected.

Thanks!

                  New to ADSelfService Plus?