Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:47:52+00:00 2026-06-12T20:47:52+00:00

Looked at: Escaping parameters in set_form_data POST , and Ruby on Rails HTTPS Post

  • 0

Looked at: Escaping parameters in set_form_data POST, and Ruby on Rails HTTPS Post Bad Request

  def send_request(params)
     host = "https://hc.mercurydev.net"
     uri = URI.parse(host)
     http = Net::HTTP.new(uri.host, uri.port)
     http.use_ssl = true
     http.verify_mode = OpenSSL::SSL::VERIFY_NONE

     xml = build_xml_for_checkout(params)


     http.start do |http|
        req = Net::HTTP::Post.new('http://www.mercurypay.com/InitializePayment')
        header = {'Host' => 'hc.mercurydev.net',  'Content-Type' =>  'text/xml; charset=utf-8', 'Content-Length' => 'length', 'SOAPAction' => 'http://www.mercurypay.com/InitializePayment'}
        req.set_form_data(header, xml)
        response = http.request(req)

     end
  end

This is the first time I have had to build my own post request in ruby, I am sure that I am missing something simple, but what?

— I have confirmation that the xml is 100% good, so it has to be something in my header or in how I’m building the request.

Edit: After looking at ruby-api-doc: I came up with this:

uri = URI.parse(host)

Net::HTTP.start(uri.hostname, uri.port,
      :use_ssl => uri.scheme == 'https').start do |http|

  req = Net::HTTP::Post.new uri.path
  req.body = xml
  req.set_form_data(header)

 res =  http.request req
end

Which returns (even if I restart my server) that I have an open HTTP session.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:47:53+00:00Added an answer on June 12, 2026 at 8:47 pm

    So ended up with this:

    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    
    req = Net::HTTP::Post.new(uri.request_uri)
    req.body = xml.to_s
    req.initialize_http_header(header)
    
    response = http.request(req)
    

    The key that I was missing was the initialize_http_header() once I got that in there the soap api accepted my submission and then is was just an issue of making sure my syntax was correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looked at several post on stackoverflow as well as other sources (online + ANT
I looked around on Stack Overflow and Agile Development with Rails but couldn't find
I looked in the Rails docs under inflector and found this message... Module deprecated
I looked through Stackoverflow and found almost identical question here . It was asked
I looked through other questions and couldn't find what I needed. Best if I
I looked around but haven't found an answer to this. I have a CentOS
I looked around and couldn't find it! Maybe I didn't look hard enough,but this
I looked at this: Returning values from nested functions in Javascript but it did
I looked in the mysql reference, and here, in stackoverflow, and looks like a
I looked through other StackOverFlow questions, but I'm a little confused. I'm trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.