Forum: Ruby on Rails Getting Remote Response via HTTP

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
HH (Guest)
on 2006-06-13 22:57
(Received via mailing list)
I am trying to query USPS to get shipping rates in my Rails app.

I am currently fighting Net:HTTP and so I thought I'd ask for some help.

USPS only accepts GET requests, no POST... So, I have something along
following lines:

@response_plain = Net::HTTP.get(USPS_SERVER_URL,

'data' is an XML string we generate elsewhere.

All I am getting back is:

getaddrinfo: No address associated with nodename

Which I am guessing is the response from whatever low-level OS call
implements this network call (?)...

Well, if I print out the string that it's using:
quest USERID="xxxxx"><Package
ainer>Flat Rate

That URL works. It is the test server USPS URL and returns a response in

So, what am I doing wrong? I have been trying variations of this for
over an
hour and I'm ready to punch the wall.
Philip Hallstrom (Guest)
on 2006-06-13 23:22
(Received via mailing list)
> 'data' is an XML string we generate elsewhere.
> hour and I'm ready to punch the wall.
Take a look at open-uri...
Guido Sohne (Guest)
on 2006-06-14 03:04
(Received via mailing list)

The code below works for me.

Maybe you want to CGI.escape your XML before making your HTTP  request

def notifyViaSMS(number, message, api, user, password)
    result = nil
    message = CGI.escape message
    request =
    Net::HTTP.start( '', 80 ) { |http| result =
http.get(request).body }

-- G.
This topic is locked and can not be replied to.