thank you for reaching out to the community, and I'm happy to look at your code. From what I can understand, the syntax looks a bit off. I took the liberty and refactored it a little and added an API exception in case something is messed up.
import os
from pprint import pprint
from hubspot import HubSpot
from hubspot.crm.contacts import PublicObjectSearchRequest, ApiException
api_client = HubSpot(access_token=os.getenv("access_token"))
public_object_search_request = PublicObjectSearchRequest(
filter_groups=[
{
"filters": [
{
"propertyName": "email",
"operator": "EQ",
"value": "test@test.com",
}
]
}
],
properties=["hs_object_id"],
limit=1,
)
try:
api_response = api_client.crm.contacts.search_api.do_search(
public_object_search_request=public_object_search_request
)
pprint(api_response)
except ApiException as e:
print("Exception when calling search_api->do_search: %s\n" % e)
I can't really speak to the issues you're currently experiencing, though. But please let me know if this helps already and/or what responses you're getting.
The total, however, speaks to the number of contacts in your case that can be found with your parameters. It doesn't mean that these are returned the response. Limit means the number of results per page. If you want to cycle to the next page, you will need to use the after argument.
If this solves it, consider helping others in the community to find answers faster by marking this as a solution. I'd certainly appreciate it.
From the snipped I posted, I excluded some details like error handling for the sake of simplicity. Regardless of the legibility of the code, I would like to focus on the actual issue: Why do I need to specify limit=2 to get a single contact by email?
Like I said, I can't speak to the problem you're facing regarding the limit. But I noticed that the syntax in the filter, filter groups and PublicObjectSearchRequest looked off. I would suggest trying that and see what responses you're getting this time, but if that doesn't help, I can't think of anything else. Maybe someone else has an idea.