Hello,
I’m currently working with the HubSpot CRM Associations API to establish connections between contacts and companies. My goal is to retrieve all associations a contact has with various companies, not just the primary contact association.
Here’s the approach I’ve taken so far:
from hubspot.crm.associations import (
BatchInputPublicAssociation,
BatchInputPublicObjectId,
ApiException as AssociationApiException,
BatchResponsePublicAssociationMulti,
)
def bulk_read_associations(associations: pd.DataFrame, from_object_type: str, to_object_type: str):
batch_input_public_object_id = BatchInputPublicObjectId(
inputs=[{“id”: from_id} for from_id in associations[“from_id”].unique()])
try:
api_response = CLIENT.crm.associations.batch_api.read(
from_object_type=from_object_type,
to_object_type=to_object_type,
batch_input_public_object_id=batch_input_public_object_id,
)
except ApiException as e:
traceback.print_exc()
print(“Exception when calling batch_api->read: %s\n” % e)
raise e
return api_response
With this code, I’m only able to fetch the primary contact associations with companies. I’m looking for guidance on how to modify this code or use a different method to access all the associations a contact has with various companies, including secondary or tertiary associations.
Any advice or insights on this matter would be greatly appreciated!
Thank you in advance for your help.
Albert
Data Lead in Deale