We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Oct 27, 2021 9:48 PM
Hi,
We've created a custom object in our hubspot instance and have figured out how to post new records into that custom object through the API. All good so far.
However, what I'm not able to figure out is how I would update a specific database record within the custom object. Is this possible? We want to how this custom object mirror a table in a third party system and the data in the table will need to be updated via the API to make this possible.
Is this possible? If not, is it possible to DELETE specific records in the custom object via the API? It's not optimal, but if I could delete a specific record in the custom object database via the API, I could then I could recreate it.
Any assistance that you could provide would be greatly appreciated.
Thanks!
Solved! Go to Solution.
Oct 28, 2021 8:51 AM
Hi @09459 ,
Hope this code helps:
<?php
$args['url'] = 'https://api.hubapi.com/crm/v3/objects/<ObjectTypeId>/<ObjectId>?hapikey=xxxxx;
$args['data']= json_encode([
"properties" =>
[
"propertyName" =>'propertyValue'
]
]);
// patch
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $args['url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, $args['data']);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Accept: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$result = json_decode($result);
Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.
Oct 28, 2021 10:52 AM
We did a small video series on custom objects that may help. Check them out here
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
Oct 28, 2021 1:42 PM
Thank you Dennis. I'm watched the video and created a Unique ID that macthing the primary ket in the table in 3rd party system. Is it now possible to update the record in the custom object using the new Unique ID from the external system? I've verified that a POST gives a duplicate error and that neither PUT or PATCH are supported (at least to the same endpoint as the POST). I'm trying to avoid having to store the rowID of the custom object record in my third party database if possible.
Oct 28, 2021 10:52 AM
We did a small video series on custom objects that may help. Check them out here
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
Oct 28, 2021 8:51 AM
Hi @09459 ,
Hope this code helps:
<?php
$args['url'] = 'https://api.hubapi.com/crm/v3/objects/<ObjectTypeId>/<ObjectId>?hapikey=xxxxx;
$args['data']= json_encode([
"properties" =>
[
"propertyName" =>'propertyValue'
]
]);
// patch
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $args['url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, $args['data']);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Accept: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$result = json_decode($result);
Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.