Read Associations v4 Python AttributeError: 'BasicApi' object has no attribute 'get_crm_v4_objects_o

Hi!

I need to read the association beetwing deals and contacts using Associations v4.
I copy the code in CRM API | Associations v4 (hubspot.com)

This code work running on hubspot.com. But when I run localy I received this error:
Cell In[65], line 2 1 try: ----> 2 api_response = client.crm.associations.v4.basic_api.get_crm_v4_objects_object_type_object_id_associations_to_object_type(object_type=“0-3”, object_id=8242381931, to_object_type=“0-1”, limit=500) 3 pprint(api_response) 4 except ApiException as e:

AttributeError: ‘BasicApi’ object has no attribute ‘get_crm_v4_objects_object_type_object_id_associations_to_object_type’

I don’t understand if I need to install something else.
Could you please help me?

Thanks in advance

Hi @PIntegration

Have you set up your local environment with Hubspot’s Python libraries?

I also see your object types say “0-3” and “0-1” when you likely want “deals” and “contacts” respectively.

If neither of those work, it might help to see what your edited code looks like (with your API key redacted of course).

- Zach

Hi Zach,

Thanks for answer.

I’m working on Azure. I installed the pack at the begining. This is my code

Hi @PIntegration

It looks like you have the default values for “id” and “after” from the API page.

zachh_0-1697464082536.png

Since you’re trying to pull a deal’s contact associations, the “id” string should be replaced with the record ID of the deal you want to check. The “after” field is not required, so you can remove it so it’s not looking for a value of “string.”

This part should look more like this:
BatchInputPublicFetchAssociationsBatchRequest(inputs=[{“id”:“12345”}])

Can you try making these changes and seeing if that fixes anything?

- Zach