Hi,
We are trying to upload an attachment when we create an outbound ticket.
When using the example provided in the PHP example, we keep getting a datatype_mismatch.
added below is a part of the code.
public function createOutboundTicket(
string $email,
string $subject,
string $description,
string $shipmentId
): stdClass {
$apiUrl = $this->apiTicketsUrl . '/outbound_email/';
$customFields = new stdClass();
$customFields->cf_shipment_id = $shipmentId;
$postObj = new stdClass();
$postObj->email = $email;
$postObj->subject = $subject;
$postObj->status = 4;
$postObj->priority = 1;
$postObj->description = $description;
$postObj->attachments = [curl_file_create(SITE_ROOT . "/img/tff.png", "image/png", "tff.png"), curl_file_create(SITE_ROOT . "/img/tff-gla.png", "image/png", "tff-gla.png")];
$postObj->custom_fields = $customFields;
$postObj->email_config_id = XXXXXXXXXXXX;
$postObj->group_id = $this->defaultGroupId;
return $this->makeRequest($apiUrl, $postObj)
This code makes use of cURL and worked until we added the attachments endpoint, which resulted in the following response:
{"description":"Validation failed","errors":[{"field":"attachments","message":"It should contain elements of type valid file format only","code":"datatype_mismatch"}]}
We have validated that the images are actually png files.
We would appreciate some help with getting this to work.
Edit: I will also add that we have changed the Content-Type to multipart/form-data.