We’ve had this VB.NET code running for almost 3 years. Today, the data is no longer going to HubSpot. Any thoughts as to what could be the issue? Has Hubspot changed something?
'Build Endpoint URL
Dim strEndpointURL As String = String.Format("https://forms.hubspot.com/uploads/form/v2/{0}/{1}", intPortalID, strFormGUID)
'Setup HS Context Object
Dim hsContext As New Dictionary(Of String, String)
hsContext.Add("hutk", strHubSpotUTK)
hsContext.Add("ipAddress", strIpAddress)
hsContext.Add("pageUrl", strPageURL)
hsContext.Add("pageName", strPageTitle)
'Serialize HS Context to JSON (string)
Dim json As New System.Web.Script.Serialization.JavaScriptSerializer
Dim strHubSpotContextJSON As String = json.Serialize(hsContext)
'Create string with post data
Dim strPostData As String = ""
'Add dictionary values
For Each d In dictFormValues
strPostData &= d.Key & "=" & Server.UrlEncode(d.Value) & "&"
Next
'Append HS Context JSON
strPostData &= "hs_context=" & Server.UrlEncode(strHubSpotContextJSON)
'Create web request object
Dim r As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(strEndpointURL), System.Net.HttpWebRequest)
'Set headers for POST
r.Method = "POST"
r.ContentType = "application/x-www-form-urlencoded"
r.ContentLength = strPostData.Length
r.KeepAlive = False
Hi, I had a similar problem. All my form API submissions stopped working on 18 Oct 2016 without any changes to my code.
After much investigation, I found this to be caused by the lack of Content Length header in the request. Before 18 Oct 2016, requests without a Content Length header were accepted by the Hubspot Form API but after 18 Oct, requests without that header all fail!
Apparently, the content length issue was most likely related to a change made by Hubspot for routing traffic to forms.hubspot.com through Akamai (411 Length Required)
The weird / worrying thing is that, now that I have added the Content-Length header, the api is still not storing my forms correctly. All fields are stored except my last form field, which is being truncated (by 5 characters). My guess is that this is caused by wrong encoding or content length interpretation by the HubSpot Form API but I’m still waiting on HubSpot support to investigate this further