More and more often, embedded HubSpot forms are failing to load on browsers with strict tracking and privacy protection. On enterprise level websites, this is simply unacceptable. But that’s a fight for another day.
Now we find ourselves converting countless forms to use the HubSpot API for form submissions, which presents many challenges. Specifically, the https://api.hubapi.com/marketing/v3/forms/ (to get the forms and fields) and https://api.hsforms.com/submissions/v3/integration/secure/submit/ (to submit the form) endpoints.
The biggest challenge is validation. The forms can have validation rules. The properties associated with the fields can have validation rules. And you guessed it. Those don’t come supplied when you query the form. Those require 2 additional API requests to get properties and property validations.
So, we make 4 API requests to get the form, get the properties, get the property validation rules, and then finally submit the form. Obviously, we cache where we can.
I’m curious what others have attempted to not only handle front-end but also back-end validation before submitting via the Forms API. There are a tremendous amount of conditions to account for.
It suuuuuuure would be helpful if the Forms API submissions (which is now legacy? but there’s no v4? or is there?) would send a response back about which fields failed to validate and why, but nope. You get a 200 whether they pass or not.
So we are just blindly trying to validate based on conditions after we retrieve those and match them with the form fields. There’s no SDK or library to account for these? No payload responses with messaging? Nothing?