limiting which association types return with company, using PHP (api v3)
I am using the PHP api. I just want a list of companies, thier names / ids, and if they are a child or parent / who is their parent. Here is the code I am experimenting with..
This does return the companies and associations but it is way way more data then I need. I do not want any other associations returned. I am finding the documentation on this lacking. The PHP api library appears to append "?associations=companies" to the end of the request which causes them to be included in the page data. The issue I am having is I get a lot more (custom) associations with it, when I only want the types:
child_to_parent_company
and
parent_to_child_company
I was hoping there may be a secret syntax not well documented such as.. associations=companies|child_to_parent_company
$associations = [ 'child_to_parent_company', 'parent_to_child_company', ];
$companies = $hubspot->crm()->companies()->basicApi()
->getPage(100, null, ['name'], null, $associations)->getResults();
// if not working, try below.
//
// 1.
// $associtations = ['child_to_parent_company,parent_to_child_company'];
//
// 2. I'm using an older version and in this case the below works
// $associtations = [
// 'associations' => 'child_to_parent_company,parent_to_child_company',
// ];
limiting which association types return with company, using PHP (api v3)
Thank you @skimura for the suggestion, I tried all 3 combinations (string, array 2 options, array 1 option using a comma in string) and I get same error each time...
Unable to infer object type from: child_to_parent_company
If this worked for you on an older version maybe I could try downgrading.
limiting which association types return with company, using PHP (api v3)
@skimura Thank you for the suggestion... that discussion is about using the type id from the schema, I tried that (id 13, 14) and getting the same error.
Unable to infer object type from: 13
To me it seems that the associations parameter requires an object type specified (in this case: company), but does not work with association types (e.g. child_to_parent_company). I would prefer to specify the association type so I can exclude associations I am not working with from the api response but it is rejecting anything but object types.
limiting which association types return with company, using PHP (api v3)
Hi, @kcal0👋 Thanks for your question. I'd like to invite some of our community experts who have experience with PHP — hey @skimura@JBeatty@danhammari do you have any suggestions for @kcal0?