Hi There - I am trying to retrieve contact details associated with a deal using associations API. I get the below error even though I have passed the parameters correctly.
TypeError: BasicApi.get_page() missing 2 required positional arguments: ‘object_type’ and ‘object_id’
Can someone clarify what is wrong with the code below? Thanks!
filter_groups = [{ "filters": [ { "propertyName": "dealstage", "operator": "EQ", "value": "closedlost" # Only closed-lost deals } ]}]search_request = { "filterGroups": filter_groups, "properties": ["dealname", "dealstage", "closedate"], "limit": 100}# Fetch deals within the specified date rangesearch_results = client.crm.deals.search_api.do_search(search_request)deals = search_results.resultsif not deals: print("No closed-lost deals found in the specified date range.") return# Process each deal to get associated contactsfor deal in deals: deal_id = deal.id deal_name = deal.properties.get("dealname") deal_close_date = deal.properties.get("closedate") print(f"Processing Deal: {deal_name}, Close Date: {deal_close_date}") # --- Get associated contacts using the Associations API --- associated_contacts = [] try: contact_associations = client.crm.associations.v4.basic_api.get_page( from_object_type="deals", from_object_id=deal_id, to_object_type="contacts", limit=100 ) if contact_associations.results: for association in contact_associations.results: contact_id = association.to_object_id try: # Fetch contact details by contact ID contact = client.crm.contacts.basic_api.get_by_id(contact_id, properties=["firstname", "lastname", "email", "jobtitle"]) contact_info = { "name": f"{contact.properties.get('firstname')} {contact.properties.get('lastname')}", "email": contact.properties.get("email"), "jobtitle": contact.properties.get("jobtitle") } associated_contacts.append(contact_info) print(f"Associated Contact: {contact_info['name']}, Email: {contact_info['email']}, Job Title: {contact_info['jobtitle']}") except ContactsApiException as e: print(f"Error retrieving contact {contact_id}: {e}")
