API | Get properties from a group of a company

SOLVE
MedeirosRodrigo
Participant

Suppouse that we have a company named CompA with companyid 20200204.

This company have a properties group named Invoice Info with a internal name invoice_info.

Inside this group have some Key:Values properties with informations needed to generate a invoice for this company as well.

 

I want a Get API call to retrieve this "invoice information" something look like:

/properties/v2/companies/20200204/properties?hapikey=myapikeystring&groups=invoice_info

 

Could sameone help me to accomplish it

0 Upvotes
1 Accepted solution

Accepted Solutions
WendyGoh
Solution
HubSpot Employee

Hey @MedeirosRodrigo,

 

Digging further into this, I believe the reason is because the internal value for property "CNPJ" is "cnpj". If we change the POST data to 

 

 

{"filterGroups":[
{
"filters": [
{
"propertyName": "cnpj",
"operator": "HAS_PROPERTY"
}
]
}
],
"properties": [ "cnpj" ]
}

 

 

You should be able to see a 200 response back. Currently it's returning blank because this property isn't used in any company records yet. 

 

Additionally, you can refer to this documentation on how to check property internal value - Manage your properties

View solution in original post

6 Replies 6
WendyGoh
HubSpot Employee

Hey @MedeirosRodrigo,

 

Just to clarify, are you looking to retrieve companies with the invoice_info property known and the return response will show the value of the invoice_info property?

 

If so, you can achieve this by using the crm search endpoint - HubSpot Search v3.

 

Here's an example:

When I POST the following endpoint:

https://api.hubspot.com/crm/v3/objects/companies/search?hapikey={{myhapikey}}

 

With the following POST body

{
    "filterGroups":[
      {
        "filters": [
          {
            "propertyName": "active_pe",
             "operator": "HAS_PROPERTY"
          }
    ]
  }
],
    "properties": [ "active_pe" ]
}

I retrieve all the companies with the active_pe known and the active_pe property value will be display on my response body. 

 

Let me know if this is what you're looking for and/or if there's any further question on this.

MedeirosRodrigo
Participant

Thank you @WendyGoh

I'll try it on next week and back to you if worked

0 Upvotes
MedeirosRodrigo
Participant

Hi @WendyGoh 
Trying through this call

curl --data "@/hs-body.json" https://api.hubspot.com/crm/v3/objects/companies/search?hapikey=<my_api_key>

 

I received it

<html>

<head>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>

<title>Error 415 Unsupported Media Type</title>

</head>

<body><h2>HTTP ERROR 415</h2>

<p>Problem accessing /crm/v3/objects/companies/search. Reason:

<pre>    Unsupported Media Type</pre></p>

</body>

</html>

----------------------------------------------------------------------------------------------

hs-body.json

{
  "filterGroups":[
   {
     "filters": [
      {
        "propertyName": "CNPJ",
        "operator": "HAS_PROPERTY"
       }
      ]
    }
   ],
 "properties": [ "CNPJ" ]
}

 

------------------------------------------------------------------------------------------

So, I fail again.

What I did wrong?

 

0 Upvotes
WendyGoh
HubSpot Employee

Hey @MedeirosRodrigo,

 

Are you calling a POST request to the crm search endpoint - HubSpot Search v3

0 Upvotes
MedeirosRodrigo
Participant

Yes, I do...

this is my call on terminal:

 

curl https://api.hubapi.com/crm/v3/objects/companies/search?hapikey=<mytoken> \
--request POST \
--header "Content-Type: application/json" \
--data '{
"filterGroups":[
{
"filters": [
{
"propertyName": "CNPJ",
"operator": "HAS_PROPERTY"
}
]
}
],
"properties": [ "CNPJ" ]
}'

 

and this is the response received:

{"status":"error","message":"There was a problem with the request.","correlationId":"<token1>","requestId":"<token2>"}

 

FYI: <tokens> tags is only to keep it safe the actual values

0 Upvotes
WendyGoh
Solution
HubSpot Employee

Hey @MedeirosRodrigo,

 

Digging further into this, I believe the reason is because the internal value for property "CNPJ" is "cnpj". If we change the POST data to 

 

 

{"filterGroups":[
{
"filters": [
{
"propertyName": "cnpj",
"operator": "HAS_PROPERTY"
}
]
}
],
"properties": [ "cnpj" ]
}

 

 

You should be able to see a 200 response back. Currently it's returning blank because this property isn't used in any company records yet. 

 

Additionally, you can refer to this documentation on how to check property internal value - Manage your properties

View solution in original post