APIs & Integrations

shlahman
Participant

Read all data from Custom Object

SOLVE

Hello,

 

Anyone can please advise how can I use the API in order to read all data from a Custom Object?

 

Thanks

 

Ariel

0 Upvotes
1 Accepted solution
cowles123
Solution
Member

Read all data from Custom Object

SOLVE

I believe I found the solution (they might have just added it).

 

You can find it within the object section of the custom object page (https://developers.hubspot.com/docs/api/crm/crm-custom-objects).
Go to /crm/v3/objects/{objectType}

Here you just need to add the custom object's internal name or the custom object's ID. 

 

As some people have mentioned, they can only see metadata. To see additional data you need to specify the additional fields (internal name). See the picture below.

 

Screen Shot 2022-10-18 at 1.39.52 PM.pngScreen Shot 2022-10-18 at 1.39.31 PM.pngScreen Shot 2022-10-18 at 1.39.10 PM.png

 

View solution in original post

22 Replies 22
VStruyf
Contributor

Read all data from Custom Object

SOLVE

I also want to find all the data for a custom object, but I get the following error:

 

The scope needed for this API call isn't available for public use. If you have questions, contact support or post in our developer forum.

 

I use the endpoint: /crm/v3/objects/{objectType}

0 Upvotes
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE

Hi @VStruyf ,

seems you have to add either the scope to your private app key or you haven't the key present in your serverless function.

0 Upvotes
VStruyf
Contributor

Read all data from Custom Object

SOLVE

Which scope should be selected? 

 

I also have the error when I try it here with the test call:  https://developers.hubspot.com/docs/api/crm/crm-custom-objects

0 Upvotes
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE

You need at least these to request custom object:
crm.schemas.custom.read, crm.objects.custom.read

0 Upvotes
VStruyf
Contributor

Read all data from Custom Object

SOLVE

They are both selected.

0 Upvotes
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE

So, if you need other than these two scopes, select then.
Then update your secret, because the scope is encoded in that key.
And make sure to process.env your key in your serverless function and provide it in headers.

0 Upvotes
VStruyf
Contributor

Read all data from Custom Object

SOLVE

Still not working... and I don't see why

0 Upvotes
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE

Still the scope error message? Check all possible scopes you need, and then always update your secret.

0 Upvotes
VStruyf
Contributor

Read all data from Custom Object

SOLVE

Yes, still the same. These are the scopes I selected:

 

crm.lists.read
crm.objects.contacts.read
crm.schemas.custom.read
crm.objects.custom.read
crm.schemas.custom.write
crm.schemas.contacts.read

0 Upvotes
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE

Maybe you need some more or some other … Depends on what you want to do. Can you describe, please.

0 Upvotes
VStruyf
Contributor

Read all data from Custom Object

SOLVE

I would like to get all the items from a custom object.

I'm trying to do that with this call: GET /crm/v3/objects/{objectType}

0 Upvotes
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE
  1. So you need a private app with scope:
    crm.schemas.custom.read
    crm.objects.custom.read
  2. Copy the key and set it as secret to your account
  3. create a serverless function and get your secret with process.env,
    provide it then in headers
  4. make a call to /crm/v3/objects/{objectType} and provide all properties you need like so: &properties=firstname&properties=lastname...

This should work.

0 Upvotes
cowles123
Solution
Member

Read all data from Custom Object

SOLVE

I believe I found the solution (they might have just added it).

 

You can find it within the object section of the custom object page (https://developers.hubspot.com/docs/api/crm/crm-custom-objects).
Go to /crm/v3/objects/{objectType}

Here you just need to add the custom object's internal name or the custom object's ID. 

 

As some people have mentioned, they can only see metadata. To see additional data you need to specify the additional fields (internal name). See the picture below.

 

Screen Shot 2022-10-18 at 1.39.52 PM.pngScreen Shot 2022-10-18 at 1.39.31 PM.pngScreen Shot 2022-10-18 at 1.39.10 PM.png

 
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE

Hey @cowles123 you are absolutely right. This is the right endpoint and one has to explicitly add all properties one wants to see. In the documentation one has to open "see all params" to find the properties param. Kind of weird ...

Thanks for your help. 😀

0 Upvotes
mwx_kk
Contributor | Platinum Partner
Contributor | Platinum Partner

Read all data from Custom Object

SOLVE

Hi guys,

here is how I finally got my data:

  1. Retrieve the schema of your custom object, i.e.  /crm/v3/schemas/objectTypeId, there you find properties used by the data you want to get
  2. Extract the name of each property and create a querystring for later use, like so "&properties=firstname&properties=lastname..."
  3. Retrieve the object from /crm/v3/objects/objectTypeId, it holds the IDs of each data-set
  4. Retrieve your data for each object-ID, like so: /crm/v3/objects/objectTypeId/objectId?portalId=1234567&properties=firstname&properties=lastname
  5. Push each response.data in an array and use sendRequest to deliver it to your frontend
0 Upvotes
DTyshetskyy
Member

Read all data from Custom Object

SOLVE

Hi guys, any update on this?
/crm/v3/schemas/{objectTypeId} mentioned in the doc, is only providing the schema for the object - metadata. Tried to run crm/v3/objects/{objectTypeId} - provides very basic info about the object with created_time etc. - no actual data

0 Upvotes
webdew
Guide | Diamond Partner
Guide | Diamond Partner

Read all data from Custom Object

SOLVE

Hi @shlahman ,

You can use this documentation regarding custom object for fetch all data :
Link : https://developers.hubspot.com/docs/api/crm/crm-custom-objects

This link will also help you regarding custom object
Link : https://www.webdew.com/blog/create-custom-objects-in-hubspot-using-api

<?php
$URL = 'https://api.hubapi.com/crm/v3/schemas/p<PORTALID>_<CUSTOMOBJECTKEY>?portalId=<PORTALID>';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

$headers = array();
$headers[] = 'Content-Type: application/json';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);


return $result;
?>

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regard.

0 Upvotes
Teun
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Read all data from Custom Object

SOLVE
Hi!

What do you want to read? Do you need the name and ID? The association's between your custom object and other objects or simply all records the custom object has?
If you check the docs, you can find all endpoints that you need. You also have a 'run in postman' option that imports a collection with great examples.

https://developers.hubspot.com/docs/api/crm/crm-custom-objects


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
shlahman
Participant

Read all data from Custom Object

SOLVE

Hi Teun,

 

Thanks for getting back to me so fast!

 

I would like to read the object data (not metadata) with all fields that avilabile in this object. Is there an option to read all the object data without providing specific ID?

 

Thanks,

 

Ariel

0 Upvotes
Teun
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Read all data from Custom Object

SOLVE
You always need the ID of the custom object you are retrieving, you do not need the record ID. If you need all properties the object has, you can retrieve its schema.
I am having issues opening the docs right now, but there is an example available in the overview of the docs.


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.