POST not passing information?

POST not passing information?

am 22.11.2005 21:24:59 von jpittard

I can put a URL in the address bar and get the desired result, but when I
post using LWP, the cgi program I am posting to is telling me that a
required parameter ('message') is missing. This is the only required
parameter, so I assume the program is not receiveing any of the parameters.

I have tried the following in my code:

======================
my $ua = LWP::UserAgent->new;
$regional_library="test";
my $req = new HTTP::Request 'POST','http://domain.com/cgi-bin/cgiprogram';
$req->content_type('application/x-www-form-urlencoded');
$req->content('test=yes&custid=JP%40mail.davidson.alumlink.c om&customer=Jame
s&message=Test+please+reply&pemail=test&subject=TestOfGsAnsw ers&GradeLevel=D
oYouSeeThis');

$req->content('query=libwww-perl&mode=dist');
my $res = $ua->request($req);

if ($res->is_success) {
print $res->content;
} else {
print $res->status_line, "\n";
}
===============

I am getting feedback from the last line print $res->status_line from the
cgi I am calling, saying that the one required parameter 'message' is
missing. When I put this in the code to debug,

print $req->as_string;

I get this:

POST http://domain.com/cgi-bin/cgiprogram Content-Type:
application/x-www-form-urlencoded
test=yes&custid=JP%40mail.davidson.alumlink.com&customer=Jam es&message=Test+
please+reply&pemail=test&subject=TestOfGsAnswers&GradeLevel= DoYouSeeThis

If I put the same information in the browser address bar as the
url.'?'.content, I get the desired result from the cgi:

http://domain.com/cgi-bin/cgiprogram?test=yes&custid=JP%40ma il.davidson.alumlink.com&customer=James&message=Test+please+ reply&pemail=test&subject=TestOfGsAnswers&GradeLevel=DoYouSe eThis

Thanks, James

Re: POST not passing information?

am 23.11.2005 13:53:08 von japhy

On Nov 22, James Pittard said:

> I can put a URL in the address bar and get the desired result, but when I
> post using LWP, the cgi program I am posting to is telling me that a
> required parameter ('message') is missing. This is the only required
> parameter, so I assume the program is not receiveing any of the parameters.

It could simply mean that the CGI program is expecting to find the
parameters in the query string, and not via STDIN.

--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://www.perlmonks.org/ % have long ago been overpaid?
http://princeton.pm.org/ % -- Meister Eckhart