Issue using the basic API for fetching company list in python

Issue ussing the basic API for fetching company list, The API doesn’t work using python 3.6

Code (taken from your website)

import hubspot
from pprint import pprint
from hubspot.crm.companies import ApiException
max_results = 500
# hapikey = ‘pat-na1-455c4653-7117-415a-9805-013ee8af7e91’
limit = 5
company_list = []
get_all_companies_url = “https://api.hubapi.com/crm/v3/objects/companies
YOUR_ACCESS_TOKEN = “pat-”
client = hubspot.Client.create(access_token=“YOUR_ACCESS_TOKEN”)
try:
api_response = client.crm.companies.basic_api.get_crm_v3_objects_companies(limit=10, archived=False)
pprint(api_response)
except ApiException as e:
print(“Exception when calling basic_api->get_crm_v3_objects_companies: %s\n” % e)

--------------

output

---------------

warnings.warn(
Traceback (most recent call last):
File “/Users/xxxx/pythonProject/pythonProject/pythonProject/pythonProject/scraper/python/hubspot_conn.py”, line 16, in <module>
api_response = client.crm.companies.basic_api.get_crm_v3_objects_companies(limit=10, archived=False)
AttributeError: ‘BasicApi’ object has no attribute ‘get_crm_v3_objects_companies’

Process finished with exit code 1

Hi,

never post tokens!
HIDE IT PLESE

# hapikey = 'pat-na1-...'

Not a python expert but I can see error there. In your custom code action use hapikey (privat app token) in this line like this:

client = hubspot.Client.create(access_token="pat-na1-...")

Best practice to test your code is to use test call in HubSpot API documentation page

and then use it in WF and then copy what you get there. Using Postman is another option. There you can choose supported libriaries listed here I personally use axios as it is easy to read and troubleshoot for me.