I am using custom form for data capture and Form API to post those submission to Hubspot. But I have found that some submissions were not posted to Hubspot, though the data is present in our database. I am not able to find out the issue as there is no similarities / patterns for those submissions.
So I started logging the responses from Hubspot after the post. I am getting 204 or 302 for all of them. But some emails were not created on hubpot, like "fg@dd.c.c".
Here is my code -
function submit_hubspot_form($form_id, $param_string)
{
$endpoint = 'https://forms.hubspot.com/uploads/form/v2/' . $portal_id . '/' . $form_id;
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $param_string);
@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);
return $status_code;
}
Can anybody please let me know what issue would have caused this?
That Forms API endpoint doesn't do any validation client-side, so it was likely a case of "failing silently" where we give you a 204 because it submitted to the API, but we didn't actually save the contact in the DB. If you'd like more strict validation, I'd recommend using the V3 endpoint: https://developers.hubspot.com/docs/methods/forms/submit_form_v3
Hi @sougata , I can't tell what you're doing that might be wrong here, but if you're being returned a 204, it should be successful. That said, I can't dig in without the following. Are you able to provide this:
A link to the form you're submitting to in your hubspot account
An example of the raw payload you're sending to HubSpot.
Any full response you're receiving from our severs.
That Forms API endpoint doesn't do any validation client-side, so it was likely a case of "failing silently" where we give you a 204 because it submitted to the API, but we didn't actually save the contact in the DB. If you'd like more strict validation, I'd recommend using the V3 endpoint: https://developers.hubspot.com/docs/methods/forms/submit_form_v3