Exception "can't convert URI::HTTPS into String"

Hello. I’m trying to to an http post to an https: url (paypal’s ipn
postback), and I’m getting this error: “can’t convert URI::HTTPS into
String”. Does anyone know what this means and how I can fix it? The
relevant code looks like this:

      PAYPAL_IPN_POSTBACK_URL = "https://www.sandbox.paypal.com"

      PAYPAL_IPN_POSTBACK_REQUEST_URI = "/cgi-bin/webscr"

http = Net::HTTP.new URI.parse(PAYPAL_IPN_POSTBACK_URL)

      ### from traces I know it gets here okay

      ### next line blows up with "can't convert URI::HTTPS into

String" ###

      http.request_post(PAYPAL_IPN_POSTBACK_REQUEST_URI,

request.raw_post) do |response|
### from traces I know it never gets here
response.read_body do |body|
STDOUT.puts body
end
end

This blows up on the second line, the call to request_post. Does
anyone know what the problem is? Incidentally, I know that there’s a
paypal gem I can use for the paypal postback, but I’ve come this far
and I’d like to get this working. Also, this is running in Ruby on
Rails.

Thanks for any help.

  • Jake
http = Net::HTTP.new URI.parse(PAYPAL_IPN_POSTBACK_URL)
      ### next line blows up with "can't convert URI::HTTPS into
  • Jake

All you have to do is put .to_s at the end of your URI::HTTP to turn it
into a url string.