Could you assist me on API key migration.
I created the new Private app then tried to execute the code
$access_token = "<access token>";
$email = "test@gmail.com";
$url = "https://api.hubapi.com/crm/v3/objects/contacts/".$email."?idProperty=email";
$headers = [
"Authorization: Bearer ".$access_token,
"Content-Type: application/json"
];
$post = array(
'properties' => array(
'online_course_completion' => 'YES'
),
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "PATCH" );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $post ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status_code == 200) {
$response_json = json_decode($response, true);
print_r($response_json);
} else {
echo "Request failed with status code: ".$status_code;
}
but I’m always getting 404, and seing the response on hubspot log, it shows:
{"status":"error","message":"resource not found","correlationId":"dec53aa7-8a2d-42b1-8c01-68724152cfa9"}
Here is the code that is working with the API key for reference:
$url = 'https://api.hubapi.com/contacts/v1/contact/email/'.$email.'/profile?hapikey=' . $hubspot_api_key;
$post = array(
'properties' => array(
array(
'property' => 'online_course_completion',
'value' => 'YES',
)
),
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json' ) );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $post ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$server_output = curl_exec( $ch );
curl_close( $ch );
Thank!