APIs & Integrations

Emrah
Member

Hs_context data issue when creating new contact

Hi,

When I post data from a Cold Fusion script, the firstname, lastname and other datas are saved on the contacts list, but the data in the hs_context is not:

Here is my CF script:

<cfset hs_context = {"hutk"= #cookie.hubspotutk#, "ipAddress"= #url.client_ip#, "pageUrl"= "http://www.example.com", "pageName"= "the page name."}>
<cfset json_context = serializeJSON(hs_context)>
<cfset post = "firstname=" & #url.first_name# & "&lastname=" & #url.last_name# & "&email=" & #url.email# & "&company=" & #url.company# 
& "&website=My_Website" & "&phone=" & #url.phone# & "&country=" & #countrycode# & "&owner=" & #url.ARep# & "&hs_context=" & #URLEncodedFormat(json_context)#>
<cfhttp url="https://forms.hubspot.com/uploads/form/v2/XXXXXX/XXXXXXXXX-XXxxx-xxxxx-xxxx-xxxxxxxxxxxx" method="post" result="httpResp" timeout="120">
	<cfhttpparam type="header" name="Accept" value="application/json" />
	<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
	<cfhttpparam type="body" value = "#post#">
</cfhttp>
<cfoutput> #post# - #httpResp.FileContent# </cfoutput> 

The output:

firstname=Emrah&lastname=Kara&email=ka654654mra123@free.fr&company=Mycompany&website=My_Website&phone=(068) 000-0022&country=US&owner=Other&hs_context=%2F%2F%7B%22pageName%22%3A%22the%20page%20name%2E%22%2C%22pageUrl%22%3A%22http%3A%5C%2F%5C%2Fwww%2Eexample%2Ecom%22%2C%22hutk%22%3A%225c147cbc92eaefd797e8d5a812b263e0%22%2C%22ipAddress%22%3A%22192%2E168%2E150%2E48%22%7D - Connection Failure

0 Upvotes
4 Replies 4
Emrah
Member

Hs_context data issue when creating new contact

I have a strange behavior,
When I post a new request, with a first_name = John and Last_name = Doe for example, it works fine, but when I go to the Form submissions page, I see that the datas are correctly filled in the left column but on the right column with name/ conversion Page/ Submitted on, the name is not the same as the left column… I have two forms with the same behavior, what can cause that?

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Hs_context data issue when creating new contact

@Emrah is your page hosted on HubSpot’s COS?

0 Upvotes
Emrah
Member

Hs_context data issue when creating new contact

I found the issue, needed to delete double slashes at the begining of json_context:
#URLEncodedFormat(Replace(json_context,"//",""))#

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Hs_context data issue when creating new contact

@Emrah I’m glad you figured it out! Please let us know if you run into any other problems.

0 Upvotes