Use return value of client.crm.objects.search_api.do_search

I’m having difficulties in using the return value that comes back from the usage of the call of client.crm.objects.search_api.do_search.

I get the following print using pprint

{‘paging’: None,
‘results’: [{‘archived’: False,
‘archived_at’: None,
‘created_at’: datetime.datetime(2023, 10, 9, 10, 26, 14, 361000, tzinfo=tzutc()),
‘id’: ‘10643518851’,
‘properties’: {‘hs_createdate’: ‘2023-10-09T10:26:14.361Z’,
‘hs_lastmodifieddate’: ‘2024-03-14T11:20:38.236Z’,
‘hs_object_id’: ‘10643518851’},
‘properties_with_history’: None,
‘updated_at’: datetime.datetime(2024, 3, 14, 11, 20, 38, 236000, tzinfo=tzutc())}],
‘total’: 1}

But failing in getting the value in the id in a variable in my python script … newby issues …

Hi @KVerheyen :waving_hand:

Contrary to most Python use cases involving dictionary-like objects, you’ll need to use dot notation when interacting with API responses made available HubSpot’s Python client library. For example, you may want to try something like this as a starting point:

response = api_client.crm.contacts.search_api.do_search(public_object_search_request=my_public_object_search_request)
for contact in response.results:
 print(contact.id)

I hope that proves helpful. Please let me know if you have any follow-up questions.