Skip to content

Conversation

@dinosimone
Copy link
Contributor

HubSpot form API states the following:

"Please Note All parameters must be URL encoded before being passed through the API, including the hs_context parameter."

If it's not encoded and request contains URL unsafe characters, it silently fails to submit by creating empty fields.

@chadwilken
Copy link

In my testing this breaks the form submission. You just need to do JSON.generate on the context object to make it work

@cbisnett
Copy link
Collaborator

Since we've got ActiveSupport can we just call to_json() on opts[:body]? Would that solve this issue?

@chadwilken
Copy link

I don't think so because we don't want to json encode the entire body just the hs_context. You could sniff that out of the body and call that on that param.

@cbisnett
Copy link
Collaborator

@chadwilken I've never used Hubspot forms so I don't have any insight here, but do we really want to convert the context to JSON or is it just supposed to be url encoded?

@chadwilken
Copy link

chadwilken commented Oct 27, 2017 via email

@cbisnett
Copy link
Collaborator

OK cool. I just wanted to make sure that converting it to JSON wasn't the wrong solution but proving the the correct results as a side-effect of conversion and URL encoding.

@dinosimone
Copy link
Contributor Author

Looping back on this. I was already encoding context with to_json in my application before passing it to the form. The problem is not in the context but rather other parameters. For instance, if you have a form that contains an email field and you pass in an email such as "myemail+test@gmail.com" it will fail due to the plus sign. I suppose this could be properly encoded by the application making the API call, but it seemes more appropriate for the API to know how to handle this. This is why the documentation states this:

"Please Note All parameters must be URL encoded before being passed through the API, including
the hs_context parameter."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants