Submit Form API with Ruby on Rails - Response 204 but no content

Solved it.

Turns out, the whole payload doesn’t need to be JSON.

This is what worked:

hs_context = { hutk: cookies[:hubspotutk],
 ipAddress: request.remote_ip,
 pageUrl: request.url,
 pageName: "EnquiryForm" 
 }.to_json

 payload = URI.escape("email=#{params[:email]}&firstname=#{params[:first_name]}&lastname=#{params[:last_name]}&venue=#{params[:venue]}&product_type=#{params[:product_type]}&hs_context=#{hs_context}")