Python API returns Companies Object not in JSON format

Hello,

I am trying to get a list of all our companies through the Hubspot API in Python.

The request returns an object that is not JSON serializable, similar to the issue posted here: https://community.hubspot.com/t5/APIs-Integrations/How-to-use-the-JSON-API-response/td-p/636379

This is a simplified version of the request i am sending:

try:
 api_response = client.crm.companies.basic_api.get_page_with_http_info(limit=10, archived=False)
 companies = client.crm.contacts.basic_api
 pprint(api_response)
except ApiException as e:
 print("Exception when calling basic_api->get_page: %s\n" % e)

This returns information that seems to be JSON-formatted, but is not json formatable using json.dumps().

Object of type CollectionResponseSimplePublicObjectWithAssociationsForwardPaging is not JSON serializable

I have tried multiple ways of fixing this, including converting it to dict before using json_dumps which leads to a datetime not serializable error.

Checking the output with https://jsonformatter.curiousconcept.com/# shows multiple errors, with a small excerpt shown here:

Any help is much appreciated!

Hi, @LKiesewetter :waving_hand: Thank you for including those details. Hey @JBeatty @taran42, do you have any thoughts on how to troubleshoot what @LKiesewetter is describing?

Thank you! — Jaycee