Hi
I need Attach a PDF File to Invoice with the API zoho books. I created a script in PHP / Curl, but i can't attach a file. The script is this:
- $pdf = curl_file_create($File_with_full_path, "application/pdf");
- access_token();
- $url = "https://books.zoho.com/api/v3/invoices/".$id."/attachment?organization_id=".$OrgId;
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 0,
- CURLOPT_FOLLOWLOCATION => false,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => array('attachment'=> $pdf),
- CURLOPT_HTTPHEADER => array(
- "Authorization: Zoho-oauthtoken ".$_SESSION["AccTok"],
- "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"
- ),
- ));
- $response = curl_exec($curl);
- curl_close($curl);
I don't know what I'm doing wrong, but according to the API documentation my script would be correct, yet I only get error messages.
I would appreciate it if you could mention to me what mistake I am making