How to retrieve all contact properties value belong to a contact (including custom properties)


#1

I’m trying to get a contact using email through

https://api.hubapi.com/contacts/v1/contact/email/sunnyle1811@something.com/profile?hapikey=demo

But this only return all the basic contact properties, not the custom ones.

Trying this : https://api.hubapi.com/contacts/v2/properties?hapikey=demo returns all the custom properties but only the definition of them, not the value, and I cannot pass email as a parameter to retrieve all custom properties value belong to a particular contact.

Please help.
Thanks


#2

Hi @sunnyle,

The GET contact by email address (and other GET contact endpoints) support adding multiple property parameters to your request. So if you wanted to see the value of customProperty1 and customProperty2 be included in the response when they have a value your request would look like:

https://api.hubapi.com/contacts/v1/contact/email/sunnyle1811@something.com/profile?hapikey=demo&property=customProperty1&property=customProperty2

The HubSpot API will only return properties when there is a value and there is now way to return all properties.

-Zack


#3

Hi everyone,
I’ve got a quick question regarding this very same issue.

Zack, you said:

My question is: should I have a large number of custom properties to be retrieved, I’ll surely bump on the HTTP GET URL size limit, which is 2083 characters roughly. Is there a way to overcome this limitation, for example by asking for the contacts list via a POST call, without having to perform two distinct calls?

Thank you,

Leonardo


#4

@leonardo.scattola Remember that the 2083 character limit is based on various browser implementations, and is not necessarily reflective of the capabilities of the server or the library you use to issue HTTP calls. For example, Apache server 2.4 has a default request line limit of 8190 characters, 8177 of which are available for the URL itself. And the CURL library, for example, allegedly has no hard limit on URL length.

Your best bet is to try your query and see what happens. You may find that your query handles just fine. However, if your HTTP library errors out, or truncates the request, you should be able to detect it. And if the request line length is too long for the HubSpot server, you should get an HTTP 414 or similar response. Only then do you need to consider breaking up your request into multiple calls.

(Side note: I’ve never tried issuing a call to a HubSpot GET endpoint as a POST request, so I don’t know if it handles it appropriately.)


#5

@leonardo.scattola if you’re requesting a specific contact by email (or a batch of specific contacts), you’ll automatically get all of the properties for that contact. Using the property= parameter with those endpoints will instead limit the response to only include the specified properties (along with a few default properties). Keep in mind that either way, the record would only include properties that are set, so if a contact doesn’t have a value for firstname, it wouldn’t be included even if you have property=firstname in the request URL.

As an example, this request returns all properties that are set for the record:
https://api.hubapi.com/contacts/v1/contact/email/testingapis@hubspot.com/profile?hapikey=demo

This only includes hs_analytics_last_url, lastmodifieddate, and associatedcompanyid (lastmodifieddate and associatedcompanyid will always be included)
https://api.hubapi.com/contacts/v1/contact/email/testingapis@hubspot.com/profile?hapikey=demo&property=hs_analytics_last_url