POST not passing information?
am 22.11.2005 21:24:59 von jpittardI 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