APIs & Integrations

danhammari
Contributor

api v3 associations: are constants defined for "fromObjectType" and "toObjectType"?

SOLVE

I have been searching through the API v3 documentation but have not been able to find a list of valid strings that would satisfy the fromObjectType or toObjectType parameters of the HubSpot CRM Associations API.

 

https://developers.hubspot.com/docs/api/crm/associations

POST /crm/v3/associations/{fromObjectType}/{toObjectType}/batch/read

 

I am also interested in using the HubSpot CRM Companies API to fetch deals associated with a given company. 

 

https://developers.hubspot.com/docs/api/crm/companies

GET /crm/v3/objects/companies/{companyId}/associations/{toObjectType}

 

I am using the Hubspot API library in PHP to query the v3 endpoints, but the PHP library also does not provide a definitions list or set of constants. All of the to_object_type and from_object_type parameters are simply defined as string variables without a closed list of options or reference to allowed constants.

 

 language: PHP

namespace: HubSpot\Client\Crm\Companies\Api

    class: AssociationsApi

   method: getAll

 

Could someone point me to where I can find a list of allowed association values? I am unsure of whether to use "deal" or "deals" or "company" or "companies" and would rather not have to guess my way through trial and error to determine which association values are valid.

1 Accepted solution
ph_alti_trading
Solution
Contributor

api v3 associations: are constants defined for "fromObjectType" and "toObjectType"?

SOLVE

Hey @dennisedson ,

Sorry to disappoint you but I'm not using the  V3 of the API. On my side I'm still using the legacy API. 😜

@danhammari 

If you are using the new API V3 I *guess* it's one of the "string" described in this reference file :
https://github.com/HubSpot/hubspot-api-php/blob/master/lib/Crm/ObjectType.php

If you are using the legacy API it's probably an integer as described in this reference file :
https://github.com/HubSpot/hubspot-php/blob/master/src/Resources/CrmAssociations.php
$hubspot->CrmAssociations()->get( {an object id}, {a from2object type id} );

Hope this help. 😃

View solution in original post

4 Replies 4
ph_alti_trading
Solution
Contributor

api v3 associations: are constants defined for "fromObjectType" and "toObjectType"?

SOLVE

Hey @dennisedson ,

Sorry to disappoint you but I'm not using the  V3 of the API. On my side I'm still using the legacy API. 😜

@danhammari 

If you are using the new API V3 I *guess* it's one of the "string" described in this reference file :
https://github.com/HubSpot/hubspot-api-php/blob/master/lib/Crm/ObjectType.php

If you are using the legacy API it's probably an integer as described in this reference file :
https://github.com/HubSpot/hubspot-php/blob/master/src/Resources/CrmAssociations.php
$hubspot->CrmAssociations()->get( {an object id}, {a from2object type id} );

Hope this help. 😃

danhammari
Contributor

api v3 associations: are constants defined for "fromObjectType" and "toObjectType"?

SOLVE

Hi ph_alti_trading,

 

Thanks for pointing out the ObjectType.php file. I tested using both the plural and singular versions of each term (e.g. company/companies, deal/deals) and found that the API was able to treat the singular and plural variants of each entity without distinction. I guess the API designers thought through the possibility that users would provide either term and allowed the API to handle them without error.

 

Meanwhile, I will use the ObjectType.php file as the source of my constants when I am scripting my association queries:

namespace: HubSpot\Crm

    class: ObjectType

  example: $hubspot_api_company_helper->associationsApi()->getAll( $hubspot_company_id, \HubSpot\Crm\ObjectType::DEALS );

dennisedson
Community Manager
Community Manager

api v3 associations: are constants defined for "fromObjectType" and "toObjectType"?

SOLVE
I forgive you @ph_alti_trading :wink
Thanks,

Dennis




HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show
dennisedson
Community Manager
Community Manager

api v3 associations: are constants defined for "fromObjectType" and "toObjectType"?

SOLVE

Hey @danhammari ,

I am going to throw a bunch of folks at this for you

@quentin_lamamy , @philx , @AndrewFisher , @twnk , @ph_alti_trading  could any of you all help out here?

Thanks,

Dennis




HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show
0 Upvotes