APIs & Integrations

RGroothuis
Participant

API call on Companies doesn't filter and doesn't return the correct fields.

I've the following CLI command to retrieve the Companies from Hubspot of which the field "type" is equal to "PARTNER". And also I specify the properties to get more data back than the default fields, but I don't get those fields. What am I doing wrong? Suggestions? 

 

curl https://api.hubapi.com/crm/v3/objects/companies \
--request GET \
--header "Authorization: Bearer ******secret*******" \
--header "Content-Type: application/json" \
--data '{ "filterGroups" : [ { "filters" : [ { "propertyName" : "type", "operator": "EQ", "value": "PARTNER" } ] } ] }' \
--data '{ "properties" : "name,address,address2,city,country,description,gps_loaction,hs_lastmodifieddate,type" }'

 

For the vallue filter field, I used both "value" and "values" but that didn't solve the problem. 

0 Upvotes
4 Replies 4
sherrychen
Participant

API call on Companies doesn't filter and doesn't return the correct fields.

This should be POST request in order to pass request body - you used GET, you only need to fill "values" if your operator is "IN". 

RGroothuis
Participant

API call on Companies doesn't filter and doesn't return the correct fields.

Thanks for the feedback, i changed the CURL into: 

 

curl https://api.hubapi.com/crm/v3/objects/companies \
--request POST \
--header "Authorization: Bearer ***secret****" \
--header "Content-Type: application/json" \
--data '{ "filterGroups" : [ { "filters" : [ { "propertyName" : "type", "operator": "EQ", "value": "PARTNER" } ] } ] }' \
--data '{ "properties" : "name,address,address2,city,country,description,gps_loaction,hs_lastmodifieddate,type" }'

 

And I do get a better response now. no error code. But I don't get any records back. This is what I get in the return: 

 

{"id":"6829787850","properties":{"createdate":"2023-01-16T23:22:53.219Z","hs_lastmodifieddate":"2023-01-16T23:22:53.219Z","hs_object_id":"6829787850","hs_pipeline":"companies-lifecycle-pipeline","lifecyclestage":"lead"},"createdAt":"2023-01-16T23:22:53.219Z","updatedAt":"2023-01-16T23:22:53.219Z","archived":false}%  

 

Any more suggestions? 

0 Upvotes
sherrychen
Participant

API call on Companies doesn't filter and doesn't return the correct fields.

It seems you are getting some results back. Are you asking to get more results? Then you should add limit parameter. Here is a request body that works for me, I did not use filterGroups - which is more useful when you need to do more complex logic like multiple "AND" filter with "OR" filter all together, but should not be a problem whether you add it or not.
Example: 

{"limit":50,"filters":[{"propertyName":"type","value":"PARTNER","operator":"EQ"}],"sorts":[{"propertyName":"hs_lastmodifieddate","direction":"DESCENDING"}],"properties":["domain","name","linkedin_company_page","about_us","facebookfans","founded_year","hs_additional_domains","hs_all_assigned_business_unit_ids","hs_analytics_source","hs_ideal_customer_profile","hs_is_target_account","hs_pipeline","hs_target_account","hs_target_account_recommendation_snooze_time","hs_target_account_recommendation_state","is_public","timezone","total_money_raised","twitterhandle","phone","twitterbio","twitterfollowers","address","address2","facebook_company_page","city","linkedinbio","state","googleplus_page","hubspot_owner_id","zip","country","website","numberofemployees","industry","annualrevenue","lifecyclestage","hs_lead_status","type","description","closedate","web_technologies"]}

0 Upvotes
RGroothuis
Participant

API call on Companies doesn't filter and doesn't return the correct fields.

No, adding the limits paramater is not the solution. With the current CURL command I don't get any company data returned, I believe the returned data is only some default data. 

But anyway, I also have learned that using the filter parameter is not working on the companies endpoint url. I need to use the search companies endpoint url: ....companies/search This gives a better result for now. 

0 Upvotes