Alex Wayne
2006-May-03 00:46 UTC
[Rails] nil.strip error While trying to post xml data over https.
I am trying to subit some xml data over https to access an API. My code so far seems to generate a very non-helpful error in the guts of the net/http library. This code produces a NoMethodError for nil.strip" require ''net/http'' require ''net/https'' require ''uri'' url = URI.parse(''www.beautifulpixel.com/index.html'') connection = Net::HTTP.new(url.host, 443) connection.use_ssl = true #This is the line that causes an error response = connection.request(Net::HTTP::Post.new(url.path, request_body)) #The error occured while evaluating nil.strip # from c:/ruby/lib/ruby/1.8/net/http.rb:1138:in `initialize_http_header'' # from c:/ruby/lib/ruby/1.8/net/http.rb:1136:in `initialize_http_header'' # from c:/ruby/lib/ruby/1.8/net/http.rb:1443:in `initialize'' # from c:/ruby/lib/ruby/1.8/net/http.rb:1556:in `initialize'' # from ./lib/ups_api.rb:74:in `initialize'' # from (irb):13 What am I missing here? -- Posted via http://www.ruby-forum.com/.
Jean-François
2006-May-03 01:00 UTC
[Rails] nil.strip error While trying to post xml data over https.
2006/5/3, Alex Wayne <rubyonrails@beautifulpixel.com>:> I am trying to subit some xml data over https to access an API. My code > so far seems to generate a very non-helpful error in the guts of the > net/http library. This code produces a NoMethodError for nil.strip" > > require ''net/http'' > require ''net/https'' > require ''uri'' > > url = URI.parse(''www.beautifulpixel.com/index.html'') > connection = Net::HTTP.new(url.host, 443) > connection.use_ssl = true > > #This is the line that causes an error > response = connection.request(Net::HTTP::Post.new(url.path, > request_body)) > > What am I missing here?I guess that : irb(main):001:0> require ''uri'' => true irb(main):002:0> URI.parse(''www.beautifulpixel.com/index.html'').host => nil irb(main):003:0> URI.parse(''http://www.beautifulpixel.com/index.html'').host => "www.beautifulpixel.com" irb(main):004:0> -- Jean-Fran?ois. -- ? la renverse. Railsfrance - http://www.railsfrance.org