From: Michael Bevilacqua-Linn Date: 2007-10-09T06:02:27+09:00 Subject: Re: newbie... be gentle ------=_Part_1365_5678462.1191877346049 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Howdy, There are a couple of things going on here: 1.) First is that you seem a bit hazy on some basic HTTP concepts. Every HTTP request has an associated method. The method determines what the HTTP server does with your request when you get it, and each method has some fairly well defined semantics specified. The two methods that you'll come across most are GET and POST. A GET request is what happens when you type a URL into a browser or click on a link. A POST is what happens when you submit a form. What you need to be doing here is submitting a GET request with two parameters named API and XML. What you're doing is submitting a POST request with the chunk of XML as the payload. With a GET request, parameters are submitted on the query string after the question mark, and multiple parameters are submitted by putting a & in between them. So the url: http://www.foo.com?bar=flux&baz=quz would have two parameters, one named bar (with the value flux) and one named baz (with the value quz). In your case the two paramaters are API (which seems to specify the API you're trying to use) and XML (which seems to contain a chunk of XML with data that API needs). I like this online tutorial here http://www.jmarshall.com/easy/http/ if you'd like to know more. 2.) There are much easier ways of working with HTTP than what you're doing up there (generally you don't want to monkey around with HTTP headers if you're doing something simple). Simplest possible GET I know of in Ruby is: require 'net/http' Net::HTTP.get_print 'www.example.com', '/index.html' More complicated examples can be found here: http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html Hope this helps. MBL On 10/7/07, 7stud -- wrote: > > Bea Martin wrote: > > I am trying to access the US Postal Service web tool for tracking. I am > > new to Ruby and web programming in general so if this is a really stupid > > question I apologize in advance. > > > > According to their site the if I access the test server with: > > http://testing.shippingapis.com/ShippingAPITest.dll?API=TrackV2&XML= > > USERID="xxxxxxxxxxxx"> > ID="xxxxxxxxxxxxx"> > > > > For one thing, that's a 'get' request, which means all the data you are > transmitting is tacked onto the end of the url. While this: > > > response = http.request_post(@path, request_body) > > end > > > > is a 'post' request, which means the data is not tacked onto the end of > the url, and it is sent by other means. However, if a program on the > server is expecting the data to be attached to the end of the url, > that's where it is going to look for it. > > > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_1365_5678462.1191877346049--