I need to update async data using Accounts Dashboard | HubSpot in private app.
Example post url mentioned here is:
https://api.hubapi.com/deals/v1/batch-async/update?hapikey=demo
Use of API keys has been depricated on November 30, 2022. Image : https://prnt.sc/JjXnHO_xH6Yl .
Also where is proper code to implement it in private app using PHP? Please provide details.
Thanks.
Hi, @ISingh2
That’s for reaching out. There is not a PHP example for the endpoint you are referencing. One place to see a PHP example, is to look at the Update a batch of deals endpoint — POST/crm/v3/objects/deals/batch/update
Here are the available HubSpot documents:
Hey, @Micole @skimura do you have a quick example you can share with @ISingh2 to help get them moving forward?
Thank you! — Jaycee
This code works,
$structured = array();
foreach($properties1 as $property => $val){
$structured[] = [“name” => $property,
“value” => $val
];
}
$private_app_token = “*****API TOKEN*****”;
$http_header = [
‘Content-Type: application/json’,
'Authorization: Bearer ’ . $private_app_token,
];
$url = ‘https://api.hubapi.com/deals/v1/batch-async/update’;
$param = [
[
“objectId” => $deal_id,
“properties” =>
$structured,
],
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $http_header);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($param));
$output = curl_exec($curl);
curl_close($curl);
@ISingh2
Hi.
I hope you find this sample code helpful.
$private_app_token = "PRIVATE_APP_TOKEN";
$http_header = [
'Content-Type: application/json',
'Authorization: Bearer ' . $private_app_token,
];
$url = '...';
$param = [
[
"objectId" => XXXX,
"properties" => [
[
"name" => "XXXXXX",
"value" => "XXXXX"
]
]
],
...
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $http_header);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($param);
$output = curl_exec($curl);
curl_close($curl);
var_dump($output);
Thanks.
@Jaycee_Lewis
Thank you for mention.
Hey, @skimura! Thank you very much 