How we can get contact id after submit data to a form with form api?

contacts

#1

Provide me some solution for, After data submit by form api.
Becoz I want to integrate deal after form API submit so need to contact id for that.

     ."firstname=" . urlencode($orderData['client_name'])
                                            . "&email=" . urlencode($orderData['client_email'])
                                            . "&lifecyclestage=" . urlencode('Customer');
                                            //. "&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 = 'https://forms.hubspot.com/uploads/form/v2/'.$portalId.'/'.$formGuid;

                                    $ch_hub_marketing = @curl_init();
                                    @curl_setopt($ch_hub_marketing, CURLOPT_POST, true);
                                    @curl_setopt($ch_hub_marketing, CURLOPT_POSTFIELDS, $str_post);
                                    @curl_setopt($ch_hub_marketing, CURLOPT_URL, $endpoint);
                                    @curl_setopt($ch_hub_marketing, CURLOPT_HTTPHEADER, array(
                                            'Content-Type: application/x-www-form-urlencoded'
                                    ));
                                    @curl_setopt($ch_hub_marketing, CURLOPT_RETURNTRANSFER, true);
                                    $response_hub_marketing    = @curl_exec($ch_hub_marketing); //Log the response from HubSpot as needed.
                                    $status_code = @curl_getinfo($ch_hub_marketing, CURLINFO_HTTP_CODE); //Log the response status code
                                    @curl_close($ch_hub_marketing);

#2

@kartik Do you have access to the workflows tool for marketing automation? You could create that logic in there which would be the easiest way. Would these be new contacts or existing contacts? I ask so I can try and help find the best use of the APIs if you don’t have access to workflows.


#3

Hi Pmanca,

I need want to create deal of that form detail so need to contact id of that detail after form submit with below code:

$endpoint = ‘https://forms.hubspot.com/uploads/form/v2/’.$portalId.’/’.$formGuid;


#4

@kartik If you cannot use the workflow tool to build it out in the GUI then you will have to hit the recently created/updated contacts endpoints. Then you can create a deal from the contacts properties that were supplied via the form detail.


#5

Hey pmanca,
Its quite confusion becoz it provide data not at same time but after some moment provide latest one data,So it cant help me for solution.

I need contact id of particular data which inserted or updated in contact for particular form So n so I create deal of for data to that contact.

One more thing i used for that like get contact id through email but same thing happened for this it cant give at a time latest contact id but after some moment it provide me that latest contact id.

Plz provide me exact solution for my requirement.


#6

@kartik The only way at the moment to get what you are looking for via the API would be through the endpoint I posted above. There you can parse through the data for those who have a recent conversion of your form and grab the contact ID so you can then use the create deal endpoint.


#7

I was able to accomplish this by using the Contact API. If you have the email address you can try:

$endpoint ="https://api.hubapi.com/contacts/v1/contact/email/{$email}/profile?hapikey={$HubspotAPI}";

The following is required only if running this back to back right after submitting the form.
need to give hubspot a second to catch up
not ideal

usleep(1000000);

$ch = @curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $endpoint
));

$resp = json_decode(curl_exec($ch), true);
$vid = $resp['vid'];