RedCap API export

Hi All,
I am new to Python with no cs background. I am trying to export data from RedCap using an API however each time I execute the script it indicates that there is an SSI certificate issue “[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)”.

I am using Pycharm in VENV. I’ve try “pip install --upgrade certifi” but still no luck.

Any suggestion or feedback is greatly appreciated!

The below is the script that I use with file path and RedCap URl redacted.

import requests
import pandas as pd

# REDCap API URL and API Token
redcap_api_url = ''
redcap_api_token = 'xxxxx'

# Construct the payload for the exportRecords API method
payload = {
    'token': redcap_api_token,
    'content': 'record',
    'format': 'json',
    'type': 'flat',  # Specify 'flat' to retrieve all data in a single flat format

# Make the request to the exportRecords API method with SSL certificate verification
response =, data=payload, verify=True)

if response.status_code == 200:
    exported_data = response.json()

    # Convert the data to a pandas DataFrame
    df = pd.DataFrame(exported_data)

    # Replace spaces in column names with underscores
    df.columns = df.columns.str.replace(' ', '_')

    # Export DataFrame to Excel
    excel_file_path = r'W:\Data\Python_Export\RC_HH_exported_data.xlsx'
    df.to_excel(excel_file_path, index=False)

    print(f"Data exported to {excel_file_path}")
    print(f"Error: {response.status_code}")

Does this help?

Hi Karl, I am using windows os. I’m not too sure where to find this in windows. Is it the program file folder? is “pip install --upgrade certifi” the same as running “/Applications/Python\ 3.7/Install\ Certificates.command”?

I’ve tried changing the url from HTTPS to http but had no luck.