API Integration - Get contact by email address

Hi, we’re doing the api keys to private apps migration currently.

For one of our integrations, we’re using “Get a contact by email address” https://legacydocs.hubspot.com/docs/methods/contacts/get_contact_by_email

When tested on postman it works (with the private app token) returning 200 and json data.

However when we do the same via our java servlet, it returns 404, which means the email is not found although it is the same email and call.

Do you have any sample code for java?

Or the v3 endpoints for get contact by email? Thanks!

Hi, @atiqah :waving_hand: thanks for reaching out. While I do not have a documented Java example, I can confirm you can use the v3 Contact endpoints to get a Contact by ID (email address for your use case).

Here’s what the documentation states:

“The idProperty query parameter doesn’t appear on the Endpoints tab due to technical limitations, but it can be used for contacts exclusively with email. To use an email address as the unique identifier, set the idProperty as email and enter the email address in place of the contact ID. This should be set as a query parameter rather than added to the request body.”

Unique identifiers and deduplication

I hope this helps a bit. Have fun building! — Jaycee

thanks jaycee!

adding idProperty=email in the params works in postman but the java servlet is still returning 404. :disappointed_face:

Here’s the java code if it helps

URL newUri = new URL("https://api.hubapi.com/crm/v3/objects/contacts/[EMAIL]?idProperty=email");
HttpURLConnection conn = (HttpURLConnection) newUri.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", "Bearer " + token);
conn.connect();

Hi Jaycee, still having the 404 issue :disappointed_face: