Python : from hubspot.files import FolderInput, ApiException --> error

Hello,

I’m trying to use the official files API to upload files to HubSpot. I used the example snippet provided in the official documentation but I encounter an error when trying to import the librairy.

I didn’t encounter any error when importing

from hubspot.crm.contacts import BatchInputSimplePublicObjectInputForCreate, ApiException. I tried to upgrade with pip install hubspot-api-client but all dependencies seem to be satisfied already.

import hubspot
from pprint import pprint
from hubspot.files import FolderInput, ApiException

client = hubspot.Client.create(
 access_token="xxxx")

folder_input = FolderInput(name="API test")

try:
 api_response = client.files.folders_api.create(folder_input=folder_input)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling folders_api->create: %s\n" % e)
Exception has occurred: ImportError
cannot import name 'FolderInput' from 'hubspot.files' (C:\Python311\Lib\site-packages\hubspot\files\__init__.py)
 File "G:\.shortcut-targets-by-id\1lxRq1qu-1mutw8lIx7LnWZlb-GNmcMnX\Duett\Hubspot\Data\ETL\python\example_upload_file_1.py", line 3, in <module>
 from hubspot.files import FolderInput, ApiException
ImportError: cannot import name 'FolderInput' from 'hubspot.files' (C:\Python311\Lib\site-packages\hubspot\files\__init__.py)

Can you please help me with this?
Thanks a lot

The import statement in the documentation is:

from hubspot.files import ImportFromUrlInput, ApiException

However the file structure is discovery/files/files, so to make it work you have to modify it to

from hubspot.files.files import ImportFromUrlInput, ApiException

You have to also modify

api_response = client.files.files.files_api.import_from_url

We have already reported this issue, but with this modification it works perfectly.