Cannot add call log recording to pipedrive

I cannot add the call log recording to pipedrive via python requests, while I can normally do this via Postman.

what I am trying is

url = "https://api.pipedrive.com/v1/callLogs/jjjj/recordings?api_token=some_code"

payload = {}
files=[
  ('file',('LOCAL_FILE_20230726024715481.mp3','rb',
           open('LOCAL_FILE_20230726024715481.mp3','rb'),'audio/mpeg'))
]
headers = {
  'Content-Type': 'multipart/form-data',
  'Accept': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

I have also tried not adding some of the headers, or loading the files in another way (say, without ‘file’ key and/ or only file binary inhold but not the filename).
I do not know how to add the info on the multipart-form file size to the request (or how to calculate it).

I am running into code 400 or this error:

content-type header: multipart missing boundary",“success”:false,“error_info”:“Please check developers.pipedrive.com for more information about Pipedrive API.”

the issue is apparently linked to this,

but I am on python and some things should be a little bit simpler here

the chunk itself is taken from Postman which is renowned for being able to generate normal code for runtimes.
I have also tried some suggested by chatgpt4 and on SO.

Pipedrive API Support was unhelpful and directed me to the community (How to add call audio recording with python requests /callLogs/<id>/recordings — Pipedrive Community), whence I got another chatgpt4 response which is incorrect, and now I am here.

So please kindly do not provide one more chatgpt4-generated response.

Thank you in advance for help in any advancement on this matter.

code on PHP. but you have to understand it. WITHOUT BINARY. When i sent with BINARY i receive error

$endpoint = self::API_VERSION_PREFIX . ‘callLogs/’ . $callLogId . ‘/recordings’;
$mimeType = ‘audio/mp3’;
$typeFile = ‘mp3’;

    $curl = curl_init();
    $post_data = ['file'=> new CURLFILE($recordFileUrl, $mimeType, 'callRecord' . $typeFile)];
    $curlOptions = [
        CURLOPT_URL => $this->getApiUrl() . $endpoint,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POST => 1,
        CURLOPT_VERBOSE => true,
        CURLOPT_POSTFIELDS => $post_data,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . $this->getAccessToken(),
            'Accept: application/json'
        ],
    ];

    curl_setopt_array($curl, $curlOptions);
    $response = curl_exec($curl);

Hey, @hylloszeryy and welcome to the community! :wave:

Our engineer took a look at this and they are able to post the recording with the following example:

url = "https://api.pipedrive.com/api/v1/callLogs/{call_id}/recordings?api_token={token}"
payload={}
files=[
  ('file',('recording.wav',open('/path/to/file/recording.wav','rb'),'audio/wav'))
]
headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Audio files are supported, so the issue shouldn’t be from there.

Let us know if that helps! :slight_smile:

Sincerely,
Helena