From: scootiePuff Date: 2007-12-04T12:06:41+09:00 Subject: Re: constructing an (xml) request properly for http post to an api thanks for responding jeff, and for your feedback. unfortunately, i kept encountering "syntax error, unexpected $end, expecting kEND" with variations of the send_email code. i tried the following instead, and i'm now able to receive an xml response: #!/usr/bin/env ruby require 'net/http' require 'uri' type = 'record' activity = 'query-data' xml_req =< 123456789 987654321 user@somedomain.com EOF req = "type=#{type}&activity=#{activity}&input=" req = req + URI.escape(xml_req) res = Net::HTTP.start('www.uptilt.com') { |http| http.post("/API/mailing_list.html", req) } puts res.body (by the way, it is not an e-mail that i am attempting to send, but rather an e-mail address, in order that i might receive statistical information via xml that is tied to that e-mail address.) On Nov 28, 8:20 pm, Jeff wrote: > I think you're creating the xml part ok, it's the previous section > that should be different. Here's what we do: > > # send email via emailLabs > # the msg parameter is actually the XML fragment that should be sent > def send_email(msg, type, activity) > req = "type=#{type}&activity=#{activity}&input=" > req = req + URI.escape(msg) > begin > Net::HTTP.start('www.uptilt.com') do |query| > response = query.post("/API/mailing_list.html", req) > @response = response.body > end > rescue > @error = true > @error_msg = "Unable to connect to Email Labs." > return false > end