CRM API | Get a contact by email address | Specify properties to return

Hi,

We currently have a serverless function that is using the endpoint

GET /contacts/v1/contact/email/:contact_email/profile

(documented here), to return all properties of a specified contact.

But we need to change it, so it returns only the specified property instead. We tried using the optional parameter “&property=x”, which apparently needs to be added to the URL, but the error message 404 is returned.

Below is the line in the JS function, returning all properties

let resultado = await fetch('https://api.hubapi.com/contacts/v1/contact/email/

<contact-email>

/profile’, {

method: ‘GET’,

headers: headers

})

The line above runs successfully with code 200.

And below is the line that we modified to try to retrieve only the property “name”:

l

et resultado = await fetch('https://api.hubapi.com/contacts/v1/contact/email/

<contact-email>

/profile&property=name’, {
method: ‘GET’,
headers: headers
})

The call above results in HTTP error 404: Resource not found.

Are we making a wrong call in the fetch?

Thanks.

@marccosta

Hi.

How about try this?

let resultado = await fetch('https://api.hubapi.com/contacts/v1/contact/email/<contact-email>/profile?property=name', {
 method: 'GET',
 headers: headers
})

If there is one GET parameter, format is “{URL}?parameter={VALUE}”.

If there are 2 or more GET parameters, format is “{URL}?parameter1={VALUE1}&parameter2={VALUE2}&…”.

Thanks.

Hi,

Thanks for replying.

We changed the code as you suggested, and the contact record was returned, but still with all properties.

After a few attempts we managed to reduce the number of returned properties using the code below:

let resultado = await fetch('https://api.hubapi.com/contacts/v1/contact/email/<email>/profile?property=<property1>&property=<property2>&propertyMode=value_only&formSubmissionMode=none&showListMemberships=false', {
 method: 'GET',
 headers: headers
 })

Thanks.