Hubspot API: Get Contact Custom Object Records with Hubl (Solved)
Seems straightforward enough, but for some reason it isn’t until it is. Sound familiar? Likely.
This walkthrough assumes you have already:
- Created a Hubspot Private App and have the Bearer Token (this request requires setting an Authorization Bearer Token using your private app token)
- Created a Hubspot Custom Object and associated it bi-directionally to Hubspot’s defined Contacts Object
- Have the Custom Object ID (this can be found in the URL path when viewing the Custom Object in Hubspot)
Step 1:
Get the association ID by using a GET request to this URL endpoint, where {your-custom-object-id} is the Custom Object number:
https://api.hubapi.com/crm/v3/associations/contacts/{your-custom-object-id}/types
Step 2:
Take the returned association id number from the GET request results and construct the Hubl logic (the first number should be a known contact ID who you know has a custom object record associated to ensure it’s working for you):
{% set associated_object_records = crm_associations({any-contacts-id-with-known-custom-object-records}, “USER_DEFINED”, ASSOCIATION_NUMBER, false) %}
Step 3:
Then output using Hubl in your HTML:
{{ associated_object_records }}
Hope this helps √
This is part of my Hubspot API shorts as I’m working through Custom Objects.