Open mamont77 opened 7 years ago
Well, it could be done with a small change in the part of building parameters, where instead of json_encode you will need to pass structure prepared for curl for post of file. Unfortunately I do not have time at the moment to modify the class for this. But if you will send a patch I will gladly apply it.
Hello, Andrii. Thank you very much. I going to send a path ASAP. Have I nice evening))
I can't send a patch right now, don't have GIT in the current workspace. However, I fixed it.
Just replace a piece of your code:
if ($method == 'GET') {
$fullURL .= $query ? '&' . http_build_query($query) : '';
}
else {
if ($query instanceof CURLFile) {
curl_setopt($ch, CURLOPT_POST, TRUE); // Enable posting.
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
array(
'attachment' => $query,
)
);
}
else {
$Q = array('JSONString' => json_encode($query));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($Q));
}
}
then call like
$attachment = __DIR__ . $invoice_attachment;
$mime_type = mime_content_type($attachment);
$file_name = basename($attachment);
$parameters = new CURLFile($attachment, $mime_type, $file_name);
try {
$result = $zoho->makeApiRequest(
'invoices/' . $invoice_id . '/attachment',
'POST',
$parameters
);
} catch (Exception $e) {
logger('Zoho Exception', $zoho->lastRequest['dataRaw']);
}
Hello, Zinok.
Could you reply is possible and you have time? Any idea how to make request like
The "attachment" should be as multipart/form-data, however, "can_send_in_mail" as the parameter.
More details: https://www.zoho.com/books/api/v3/invoices/attachment/#add-attachment-to-an-invoice