Submit data to a form 403 Error


Hi I'm try to send from data using PHP i'm getting this issue every time
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: UUZMxXLiHhyiEJCJIrInKebJlH--b1Z8-1q6E_uhwMssB0BAU6zAsg==

My PHP code is like this

<?php //Process a new form submission in HubSpot in order to create a new Contact. $hubspotutk = $_COOKIE['hubspotutk']; //grab the cookie from the visitors browser. $ip_addr = $_SERVER['REMOTE_ADDR']; //IP address too. $hs_context = array( 'hutk' => $hubspotutk, 'ipAddress' => $ip_addr, 'pageUrl' => '', 'pageName' => 'Example Title' ); $hs_context_json = json_encode($hs_context); //Need to populate these variable with values from the form. $str_post = "firstname=" . urlencode($firstname) . "&lastname=" . urlencode($lastname) . "&email=" . urlencode($email) . "&phone=" . urlencode($phonenumber) . "&company=" . urlencode($company) . "&hs_context=" . urlencode($hs_context_json); //Leave this one be //replace the values in this URL with your portal ID and your form GUID $endpoint = '{portalId}/{formGuid}'; $ch = @curl_init(); @curl_setopt($ch, CURLOPT_POST, true); @curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post); @curl_setopt($ch, CURLOPT_URL, $endpoint); @curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/x-www-form-urlencoded' )); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = @curl_exec($ch); //Log the response from HubSpot as needed. $status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE); //Log the response status code @curl_close($ch); echo $status_code . " " . $response; ?>


Hi @saurabh442,

I believe that error comes from your own server configuration, not the HubSpot API. Here's some information I found regarding that error and Amazon CloudFront: