From 87791cfacd0afd3a13950c6bf270916d701d144f Mon Sep 17 00:00:00 2001 From: Dino Simone Date: Thu, 3 Aug 2017 01:13:02 -0400 Subject: [PATCH] Form body should be URL encoded; see https://developers.hubspot.com/docs/methods/forms/submit_form --- lib/hubspot/connection.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hubspot/connection.rb b/lib/hubspot/connection.rb index 7c87e2dc..1725c58f 100644 --- a/lib/hubspot/connection.rb +++ b/lib/hubspot/connection.rb @@ -97,7 +97,8 @@ class FormsConnection < Connection def self.submit(path, opts) url = generate_url(path, opts[:params], { base_url: 'https://forms.hubspot.com', hapikey: false }) - post(url, body: opts[:body], headers: { 'Content-Type' => 'application/x-www-form-urlencoded' }) + params = CGI.escape(opts[:body].map{|k,v| "#{k}=#{v}"}.join("&")) + post(url, body: params, headers: { 'Content-Type' => 'application/x-www-form-urlencoded' }) end end end