Getting Data from API using python - getting certificate error

Hi All,

We are evaluating Monday as a possible new platform to replace our current PMO solution, and I’m trying to test out the API.

I was able to generate an API key using an admin account and attempted to connect to the API using the simple example code provided in the documentation.

import requests
import json

apiKey = "NotMyRealAPIKey"
headers = {"Authorization" : apiKey, "API-Version" : "2023-04"}

query2 = 'query { boards (limit:1) {id name} }'
data = {'query' : query2}

r = requests.post(url=apiUrl, json=data, headers=headers)

However I was surprised to immediately get an error when running this:

Exception has occurred: SSLError

HTTPSConnectionPool(host=‘api.monday.com’, port=443): Max retries exceeded with url: /v2 (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)’)))

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)

Would appreciate if I’m missing something obvious here.

Hey @ryfrank,

Welcome to the community!

Not 100% sure if this will resolve that specific error, but I see you’re calling API version 2023-04 which is no longer supported. Try calling 2024-04 (RC), 2024-01 (stable), or 2023-10 (maintenance) and let me know what happens!

Best,
Rachel

import requests
import json

apiKey = "notForSharing"
apiUrl = "https://api.monday.com/v2"
headers = {"Authorization" : apiKey, "API-Version" : "2024-01"}

query2 = 'query { boards (limit:1) {id name} }'
data = {'query' : query2}

r = requests.post(url=apiUrl, json=data, headers=headers)

Same response. Got the same when I tried another box here as well. I took the code from Making your first request

Gotcha - well at least we got that updated!

I just tested the same code sample on my end, and I didn’t get any errors. In my experience, the error you’re getting is for the SSL cert on the client-side. I did a little research and found this discussion which may be helpful for resolving it!

Best,
Rachel

100% appears to be some kind of proxy issue that I’m going to have to try and understand on my end - is I use verify=False as part of the post call it works fine. Thanks for the linked resources

Glad you at least have a workaround! Feel free to reach out with any other questions :slight_smile:

My assumption would your environment hasn’t been configured to trust the Root CA used for their certificate. Depending on environment you may need to add it to some certificate store.

1 Like

That appears to be the issue - using the resources provided I installed the pip-system-certs module that seems to be forcing the correctly trusted root CA cert to be used and I can query with no issues. Thanks everyone!

1 Like