APIs & Integrations

piyushgoyal
Member

Getting Error [400] when trying to fetch deals by ownerID and contact emails

import hubspot
from pprint import pprint
from hubspot.crm.deals import PublicObjectSearchRequest, ApiException

client = hubspot.Client.create(access_token="<KEY>")

public_object_search_request = PublicObjectSearchRequest(filter_groups=[{"filters":[{"value":"<OWNER_ID>","propertyName":"hubspot_owner_id","operator":"EQ"},{"values":["john_doe@test.com"],"propertyName":"associations.contact.email","operator":"IN"}]}], limit=10, after=0)
try:
    api_response = client.crm.deals.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)
1 Reply 1
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Getting Error [400] when trying to fetch deals by ownerID and contact emails

Hi @piyushgoyal ,


I'm not sure you can search through associated object properties, it seems that you can only search for the associated contact ID.


This works;

{
    "filterGroups": [
        {
            "filters": [
                {
                    "propertyName": "hubspot_owner_id",
                    "operator": "EQ",
                    "value": "<OWNER_ID>"
                },
                {
                    "propertyName": "associations.contact",
                    "operator": "IN",
                    "values": ["<CONTACT_ID>"]
                }
            ]
        }
    ],
    "properties": ["dealname"]
}

While trying to access `associations.contact.email` doesn't.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.