How to add call audio recording with python requests /callLogs/<id>/recordings

dandaanzema
dandaanzema Member Posts: 1 VERIFIED MEMBER
edited April 2024 in Workflow Automation #1

I need the working example of how I can upload an audio recording to a call activity in Pipedrive with some pythonic library .

I ask to provide the complete working example instead of suggesting the basic idea, because I have already tried a lot of ways of passing header parameters and those do not work in this case, and those suggestions are largely not based on the pipedrive experience.

The idea o reach out to the node.js/ php official libraries is so far a last resort due to the complexity of another logic of the automation that is in the script.

Thanks in advance for any assistance in this question.

Answers

  • Manuel Oliveira
    Manuel Oliveira Admin Posts: 1,332 COMMUNITY MANAGER
    1000 Comments 250 Likes 25 Answers Third Anniversary

    Hi @dandaanzema , in this particular case, you are more likely to find the help you are looking for via our developer community here.

  • mivk67
    mivk67 Member Posts: 1 VERIFIED MEMBER
    First Comment
    edited August 2023 #3
    1. values for your API endpoint, API key, and call log ID.
    python
    
    Copy code
    api_url = 'YOUR_API_URL' api_key = 'YOUR_API_KEY' call_log_id = 'call_log_id' endpoint = f'{api_url}/callLogs/{call_log_id}/recordings' headers = {'Authorization': f'Bearer {api_key}'} 
    
    1. Read the Recording File:
    2. Read the audio recording file that you want to upload.
    python
    
    Copy code
    recording_file_path = 'path/to/your/recording.wav' with open(recording_file_path, 'rb') as recording_file: recording_data = recording_file.read() 
    
    1. Make the POST Request:
    2. Use the requests.post() method to send the audio recording data to the API endpoint.
    python
    
    Copy code
    response = requests.post(endpoint, headers=headers, data=recording_data) 
    
    1. Handle the Response:
    2. Check the response status code to ensure the recording was successfully added.
    python
    
    Copy code
    if response.status_code == 201: print('Recording added successfully.') else: print(f'Error: {response.status_code}') 
    

    Here's the complete example:

    python
    
    Copy code
    import requests api_url = 'YOUR_API_URL' api_key = 'YOUR_API_KEY' call_log_id = 'call_log_id' endpoint = f'{api_url}/callLogs/{call_log_id}/recordings' headers = {'Authorization': f'Bearer {api_key}'} recording_file_path = 'path/to/your/recording.wav' with open(recording_file_path, 'rb') as recording_file: recording_data = recording_file.read() response = requests.post(endpoint, headers=headers, data=recording_data) if response.status_code == 201: print('Recording added successfully.') else: print(f'Error: {response.status_code}') 
    

    Please replace 'YOUR_API_URL', 'YOUR_API_KEY', 'call_log_id', and 'path/to/your/recording.wav' with your actual API details and recording file path.

    Keep in mind that the specific implementation might vary depending on the API documentation and requirements of the service you're interacting with. Always refer to the official API documentation for accurate and up-to-date information on how to add call audio recordings using their API.

This discussion has been closed.