APIs & Integrations

YVasudevon
Member

Unable to get all the data/details for a specific Hubspot Contact

SOLVE
Hi..
I’m trying to get all the data/details for a specific "contact" via GET method but failed.
Tried below URL’s in the POSTMAN but failed.. instead getting data for 100 contacts with different details.
https://api.hubapi.com/crm/v3/objects/contacts?properties=firstname&value=Hassan
https://api.hubapi.com/crm/v3/objects/contacts/properties?property=firstname&value=Hassan
Please assist on this.. Urgent
Note: https://developers.hubspot.com/docs/api/crm/contacts
0 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

Hi @YVasudevon ,

You are currently using an endpoint that retrieves multiple contacts instead of searching for a single contact. If you want to search for a contact with firstname 'Hassan' you should use the CRM Search API:

 

Here are some examples:
NodeJS

 

const hubspot = require('@hubspot/api-client')

const hubspotClient = new hubspot.Client({ accessToken: 'YOUR_ACCESS_TOKEN' })

const PublicObjectSearchRequest = {
  filterGroups: [{ filters: [{ value: 'Hassan', propertyName: 'firstname', operator: 'EQ' }] }],
  sorts: ['firstname'],
  properties: ['firstname', 'lastname'],
  limit: 10,
  after: 0,
}

try {
  const apiResponse = await hubspotClient.crm.contacts.searchApi.doSearch(PublicObjectSearchRequest)
  console.log(JSON.stringify(apiResponse.body, null, 2))
} catch (e) {
  e.message === 'HTTP request failed' ? console.error(JSON.stringify(e.response, null, 2)) : console.error(e)
}

 

 

CURL:

 

curl --request POST \
  --url https://api.hubapi.com/crm/v3/objects/contacts/search \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "filterGroups": [
    {
      "filters": [
        {
          "value": "Hassan",
          "propertyName": "firstname",
          "operator": "EQ"
        }
      ]
    }
  ],
  "sorts": [
    "firstname"
  ],
  "properties": [
    "firstname",
    "lastname"
  ],
  "limit": 10,
  "after": 0
}'

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

0 Upvotes
7 Replies 7
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

Hi @YVasudevon ,

You are currently using an endpoint that retrieves multiple contacts instead of searching for a single contact. If you want to search for a contact with firstname 'Hassan' you should use the CRM Search API:

 

Here are some examples:
NodeJS

 

const hubspot = require('@hubspot/api-client')

const hubspotClient = new hubspot.Client({ accessToken: 'YOUR_ACCESS_TOKEN' })

const PublicObjectSearchRequest = {
  filterGroups: [{ filters: [{ value: 'Hassan', propertyName: 'firstname', operator: 'EQ' }] }],
  sorts: ['firstname'],
  properties: ['firstname', 'lastname'],
  limit: 10,
  after: 0,
}

try {
  const apiResponse = await hubspotClient.crm.contacts.searchApi.doSearch(PublicObjectSearchRequest)
  console.log(JSON.stringify(apiResponse.body, null, 2))
} catch (e) {
  e.message === 'HTTP request failed' ? console.error(JSON.stringify(e.response, null, 2)) : console.error(e)
}

 

 

CURL:

 

curl --request POST \
  --url https://api.hubapi.com/crm/v3/objects/contacts/search \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "filterGroups": [
    {
      "filters": [
        {
          "value": "Hassan",
          "propertyName": "firstname",
          "operator": "EQ"
        }
      ]
    }
  ],
  "sorts": [
    "firstname"
  ],
  "properties": [
    "firstname",
    "lastname"
  ],
  "limit": 10,
  "after": 0
}'

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
YVasudevon
Member

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

Hi Teun.. Good day.

I'm getting below error..

 

Error 405 Method Not Allowed
0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

Can you share what you tried? Cause the above code is tested and should work.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
YVasudevon
Member

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

It's working actually. Apologies for the above reply.

Anyway I want to try for search for "Phone" and "Email".. So I tried below for phone.

 

{
  "filterGroups": [
    {
      "filters": [
        {
          "value": "60123456789",
          "propertyPhone": "phone",
          "operator": "EQ"
        }
      ]
    }
  ],
  "sorts": [
    "phone"
  ],
  "properties": [
    "phone"
  ],
  "limit": 10,
  "after": 0
}

 

But I got below error.

 

{
    "status": "error",
    "message": "Invalid input JSON on line 9, column 9: Cannot build Filter, some of required attributes are not set [propertyName]",
    "correlationId": "15028149-ebc2-41bc-9660-29373dc45139"
}​

 

0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

Hi @YVasudevon ,

 

Keep 'propertyName' as 'propertyName'. You do not have to edit the 'Name' but simple set a different property after the :



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

HI @YVasudevon 


Try this for the phone:

 

{
  "filterGroups": [
    {
      "filters": [
        {
          "value": "60123456789",
          "propertyName": "phone",
          "operator": "EQ"
        }
      ]
    }
  ],
  "sorts": [
    "phone"
  ],
  "properties": [
    "firstname",
    "lastname",
    "phone"
  ],
  "limit": 10,
  "after": 0
}

 

 

And this for the email:

 

{
  "filterGroups": [
    {
      "filters": [
        {
          "value": "test@email.com",
          "propertyName": "email",
          "operator": "EQ"
        }
      ]
    }
  ],
  "sorts": [
    "email"
  ],
  "properties": [
    "firstname",
    "lastname",
    "phone",
    "email"
  ],
  "limit": 10,
  "after": 0
}

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Unable to get all the data/details for a specific Hubspot Contact

SOLVE

Keep in mind that this can still return multiple contacts if you have multiple contacts with a firstname of value 'Hassan'.

You can specify which properties you want to see in the 'properties' array.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes