From: Jeff Date: 2007-11-29T13:20:50+09:00 Subject: Re: constructing an (xml) request properly for http post to an api On Nov 28, 7:15 pm, scootiePuff wrote: > hello, > > goal: send a request that includes xml syntax via http post to > emaillabs' api > problem: would like help in constructing the (xml) request properly 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 You don't need those @ variables of course, I'm just copying and pasting from our code, but hopefully it sheds some light. The main difference is we're constructing the first part differently, and making sure we escape the xml first. Jeff softiesonrails.com essentialrails.com