Python: unable to request API

Hi there!

I managed to connect to the API via Python by making a private app on a test account and using the token I got, but I can’t make requests.

When I try to call, for example:

api_client.crm.contacts.get_all()

I get an error message

coneos_0-1681707915436.png

MaxRetryError: HTTPSConnectionPool(host='api.hubapi.com', port=443): Max retries exceeded with url: /crm/v3/objects/contacts?limit=100 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

Any idea on what I am doing wrong here?

Thanks a lot!

iAluko_1-1709027535425.png

Corentin

Hi, @CGuillo :waving_hand: Thanks for reaching out. Can you provide any additional details, code snippets, or screenshots to help provide our community with more info, please?

Hey, @taran42 do you have any thoughts on the next steps for @CGuillo? Or suggestions on specific additional info they can provide so the community can better understand the root issue?

Thank you! – Jaycee

Hi @Jaycee_Lewis :slightly_smiling_face: thanks for your answer!

Here is the code and the error. And below is the private app in my app test account. I have tried with a token, I have tried with the API key. I don’t understand how to correct the error :frowning:

It seems like there is a problem with the URL you are trying to reach. According to the error message, the SSL certificate associated with that URL is no longer valid. It looks like the API is calling to that URL, failing because of the invalid SSL, then trying again, failing again for the same reason, and so on until it’s hitting that max limit of 100 calls, then erroring out.

MaxRetryError: HTTPSConnectionPool(host='api.hubapi.com', port=443): Max retries exceeded with url: /crm/v3/objects/contacts?limit=100 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

You’ll need to contact your, or the site’s, administrator and get the SSL certificate resolved first. Then you should be able to make the calls via the API.

hi @taran42 :slightly_smiling_face: Thanks for your answer and sorry for the delay! I felt a bit discouraged and stopped coming.

Well, the people who could have helped in my firm are gone. Nobody knows what to do including me. Could you explain how to do this safely please? :slightly_smiling_face:

Also, I managed to get a little something (like 10 contacts maybe) by simply writing this in the url bar of my browser: https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=…

I wonder why it works with the browser but not in a jupyter notebook?

Thanks a lot, have a nice day,

Corentin

Hi :slightly_smiling_face:

It works with PyCurl so I’ll be using this instead of requests. Just searching how to get more than 20 items per call now :slightly_smiling_face:

@CGuillo I’m glad you got it working! To you earlier point, yes, you can pull contacts in JSON format via a URL.

Also, if you want to get multiple contacts, try looking at the parameters you have set. Take a look here for more information: Get All Contacts