Sending http post request in Ruby by Net::HTTP

The second argument of Net::HTTP#post needs to be a String containing the data to post (often form data), the headers would be in the optional third argument.


Try this:

For detailed documentation, take a look at: http://www.rubyinside.com/nethttp-cheat-sheet-2940.html

require 'uri'
require 'net/http'

uri = URI('https://api.site.com/api.dll')
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true

request = Net::HTTP::Post.new(uri.path)

request['HEADER1'] = 'VALUE1'
request['HEADER2'] = 'VALUE2'

response = https.request(request)
puts response