From: lasitha Date: 2009-02-10T21:51:22+09:00 Subject: Re: simple HTTP Post Xml request On Tue, Feb 10, 2009 at 4:52 PM, Me Me wrote: > I tried: > > url='http://manage.encoding.com/' > http=Net:HTTP.new(url) > xml_response = http.post('/','') > > and I get > getaddrinfo: no address associated with hostname (Socket Error) With the disclaimer than i haven't used net/http much, the following three forms all seem to post to manage.encoding.com and get back a 200 OK response. require 'net/http' require 'uri' # this is the closest form to the one you tried # note that the http protocol is excluded # (presumably because we're explicitly constructing an HTTP object) http = Net::HTTP.new('manage.encoding.com') response = http.post('/', "xml=#{some_xml_data}") # this form uses the post_form class method and a parsed uri # note the trailing slash is necessary # note also the (cleaner) use of a hash over a string for post params url = URI.parse('http://manage.encoding.com/') response = Net::HTTP.post_form(url, { 'xml' => some_xml_data }) # this form opens the tcp connection and http session, # ensuring they are closed after the block executes url = URI.parse('http://manage.encoding.com/') Net::HTTP.start(url.host, url.port) do |http| response = http.post(url.path, "xml=#{some_xml_data}") end HTH, lasitha