I did try to send the curl request to HUBSPOT using the following endpoint "https://forms.hubspot.com/uploads/form/v2/{portalId}/{formGuid}". {portalId} and {formGuid} was replaced correctly.
When the request is sent the status code 204 is returned as a response but there is no data added.
The codebase on the server and on my localhost is exactly the same. It is working just fine on my localhost but not working on the server.
Please can anybody help to determine the issue as not able to figure out the possible reasons for this? There are many questions regarding the same.
Thanks in advance.
Function for api call.
public static function api($post_values)
{
self::getKeyValues();
//replace the values in this URL with your portal ID and your form GUID
$endpoint = 'https://forms.hubspot.com/uploads/form/v2/{portalId}/{formGuid}';
$endpoint = str_replace("{portalId}", self::$portalID, $endpoint);
$endpoint = str_replace("{formGuid}", self::$formID, $endpoint);
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_values);
@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);
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$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);
return $status_code; //if 204 status code is printed that means for has been submitted successfully.
}