How to create Sales order attachment in Zoho Books with using Sales Order attachment API?

How to create Sales order attachment in Zoho Books with using Sales Order attachment API?

I will try lots of way to solve this issue but no any work if any one have solution?

Try 1

<?php

$file_name_with_full_path = 'c:image_path_here';


if (function_exists('curl_file_create')) { // php 5.6+
  $cFile = curl_file_create($file_name_with_full_path);
} else { // 
  $cFile = '@' . realpath($file_name_with_full_path);
}
echo $cFile;

$post = array(
    'authtoken' => '1000.805999fce4869cacf18af4bbbb990bb6.dfsdfsd3333333',
    'organization_id' => '123456789',
    'can_send_in_mail' => 'true',
    'attachment'=> $cFile);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 

$r = curl_exec($ch);
curl_close ($ch);
print_r($r);
exit();
?>

Try 2

$file_path          = $file->getPathname();
        $file_mime          = $file->getMimeType();
        $file_uploaded_name = $file->getClientOriginalName();
        $getFile = file_get_contents( $file_path );

       

        $data = "[
            {
                'multipart' : [
                    {
                    'filename' : ".$file_uploaded_name.",
                    'Mime-Type': ".$file_mime.",
                    'contents' : ".$getFile.",
                    }
                ]
            }
        ]";

        $postRequest = "{
            'attachment' : " . $data . ",
        }";

       print_r($postRequest);
       
        $client = new Client();
        $tokens = Token::find(1);
        $token = $tokens->token;

        $url = "https://books.zoho.com/api/v3/salesorders/" . $so_id . "/attachment?organization_id=12345678";
        $response = $client->request('POST', $url, [
            'headers' => [
                'Authorization' => 'Zoho-oauthtoken ' . $token,
                'Content-Type' => 'application/x-www-form-urlencoded',
            ],
            'form_params' => [
                'JSONString' => $postRequest,
            ],
        ]);

        $responseBody = $response->getBody()->getContents();
         
        return $responseBody;