Issue with Python Requests Library - SSL Error

70 Views Asked by At

I'm currently working on a Python project where I'm using the requests library to make HTTP requests. However, I'm encountering an SSL error when trying to connect to a specific API endpoint. Here's the code snippet:

import requests

url = 'https://example.com/api/data'
response = requests.get(url)

print(response.text)

The error message I'm receiving is:

requests.exceptions.SSLError: HTTPSConnectionPool(host='example.com', port=443): Max retries exceeded with url: /api/data (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))

I've tried updating the certifi package and setting verify=False in the request, but the issue persists. How can I resolve this SSL error and successfully make requests to the API?

0

There are 0 best solutions below