'BatchApi' object has no attribute 'post_crm_v3_objects_contacts_batch_create'

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'

Hi, @austin_moore :waving_hand: Thanks for your question. I’d like to invite several of our community members to the conversation — hey @ChrisoKlepke @JBeatty, do you have any Python-related suggestions you can give to @austin_moore?

One good debugging step I found is to print or log the dir() of the object you’re calling methods on, like dir(client.crm.contacts.basic_api). To see the available methods and help verify whether the method you’re trying to call exists.

Best,

Jaycee

Thank you Jaycee. Thank you for the recommendation. If this is not the correct method, then it could be that your documentation is not up to date, as this is the recommended method for this action. Thank you. I’ll reply back here if I can identify the correct method.

It looks like this has been replaced by a more simple ‘create’ as seen below.

I have verified that this works as expexted. Thank you!

client.crm.contacts.basic_api.create