I’m trying to send contact data from my website form to HubSpot but getting a 403 error from CloudFront. The error states that the distribution doesn’t support the HTTP method I’m using and only allows cacheable requests.
403 ERROR
The request could not be satisfied.
This distribution is not configured to allow the HTTP request method that was used for this request. The distribution supports only cachable requests.
Generated by cloudfront (CloudFront)
Request ID: abcDEF123xyz456...
Here’s my PHP code that submits the contact info:
<?php
$contact_data = array(
'properties' => array(
array(
'property' => 'email',
'value' => '[email protected]'
),
array(
'property' => 'firstname',
'value' => 'John'
),
array(
'property' => 'lastname',
'value' => 'Smith'
),
array(
'property' => 'phone',
'value' => '5551234567'
)
)
);
$json_data = json_encode($contact_data);
$api_url = 'https://app.hubspot.com/contacts/v1/contacts?hapikey=' . $api_key;
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($curl, CURLOPT_URL, $api_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$errors = curl_error($curl);
curl_close($curl);
echo "Errors: " . $errors;
echo "\nHTTP Code: " . $http_code;
echo "\nAPI Response: " . $result;
?>
I tested this on both HTTPS and HTTP environments but neither worked. What could be causing this CloudFront issue?