Hello!
I’m working on pythonically adding contacts to our Hubspot CRM.
Currently I have tried two methods, both which result in a similar attribute error. For each, I have taken code straight from the CRM API Contact Documentation. I have only altered the code by removing associations and converting each into a function.
A link to the documentation page (you still must search the correct header ‘Create’ or ‘Create A Batch of Contacts’ to find the code I copied) and resulting errors included, as well as the relevant code for each.
Please advise on the best method for solving these errors. Thank you!
Create
AttributeError: ‘BasicApi’ object has no attribute ‘post_crm_v3_objects_contacts’
def r562706_create_contact(f_name=False, l_name=False, phone=False, email=False😞 client = hubspot.Client.create(access_token=access_token) #associations = [ {"types": [{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 0}], "to": {"id": "string"}} properties = { "mcn_life_cycle": "Cold Lead", "lead_source": "MerCury" } if f_name: properties["firstname"] = f_name if l_name: properties["lastname"] = l_name if phone: properties["phone"] = phone if email: properties["email"] = email simple_public_object_input_for_create = SimplePublicObjectInputForCreate(properties=properties)cont = r562706_create_contact('Austin', 'Test','(443) 207-0301', 'Test@Tester.com')AttributeError: 'BasicApi' object has no attribute 'post_crm_v3_objects_contacts'
Create a batch of contacts
Documentation Link:
AttributeError: ‘BatchApi’ object has no attribute ‘post_crm_v3_objects_contacts_batch_create’
def r562706_create_contact_b(f_name=False, l_name=False, phone=False, email=False😞 client = hubspot.Client.create(access_token=access_token) #associations = [{"types":[{"associationCategory":"HUBSPOT_DEFINED","associationTypeId":0}],"to":{"id":"string"}}] properties = { "mcn_life_cycle": "Cold Lead", "lead_source": "MerCury" } if f_name: properties["firstname"] = f_name if l_name: properties["lastname"] = l_name if phone: properties["phone"] = phone if email: properties["email"] = email inputs = [{"properties": properties}] #{"associations":associations, batch_input_simple_public_object_input_for_create = BatchInputSimplePublicObjectInputForCreate(inputs=inputs) try: api_response = client.crm.contacts.batch_api.post_crm_v3_objects_contacts_batch_create(batch_input_simple_public_object_input_for_create=batch_input_simple_public_object_input_for_create) pprint(api_response) except ApiException as e: print("Exception when calling batch_api->post_crm_v3_objects_contacts_batch_create: %s\n" % e) return api_responsecont = r562706_create_contact_b('Austin', 'Test', '(443) 207-0301', 'Test@Tester.com')AttributeError: 'BatchApi' object has no attribute 'post_crm_v3_objects_contacts_batch_create'