APIs & Integrations

AmeeNKhan24
Member

Search request for companies returns all companies instead the one by domain in HubSpot API

I do have a company created in HubSpot and the code below works with the exception that no matter what I pass to setValue() it always returns the entire list of all companies on file instead only the one existing i.e. hubspot.com

tried it also with setPropertyName('hubspot') - same result.

Any ideas? code

BTW. I asked the HubSpot community already but no one replied yet.

public function searchCompany($company_domain)
{

    $filter = new \HubSpot\Client\Crm\Companies\Model\Filter();
    $filter->setOperator('EQ')->setPropertyName('domain')->setValue($company_domain);

    $searchRequest = new \HubSpot\Client\Crm\Companies\Model\PublicObjectSearchRequest();
    $searchRequest->setFilterGroups([$filter]);

    try {
        $response = $this->hubspot_client->crm()->companies()->searchApi()->doSearch($searchRequest);
        return $response;
    } catch (ApiException $e) {
         return $e->getMessage();
    }

}

 

0 Upvotes
1 Reply 1
TiphaineCuisset
Community Manager
Community Manager

Search request for companies returns all companies instead the one by domain in HubSpot API

Hi @AmeeNKhan24 

 

Thank you for reaching out.

 

I want to tag some of our experts on this - @Bryantworks @Teun do you know what could be happening here? 

 

Thank you!

Best

Tiphaine


Saviez vous que la Communauté est disponible en français?
Rejoignez les discussions francophones en changeant votre langue dans les paramètres !

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


0 Upvotes