You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Chris Pizzo <ch...@artinside.com> on 2002/10/31 16:28:32 UTC
Novice - How would I add a hidden form field to a LWP::UserAgent call?
Hi,
I'm trying to post data to a server that requires a hidden form field.
This is what I'm doing:
my $content = "info=somedata";
my $rec_len = length($content);
my $send_url = new URI::URL($url);
my $hdrsend = new HTTP::Headers('Content-length' => $rec_len);
$hdrsend->header('Content-type' => 'text/html');
my $reqest = new HTTP::Request('POST', $send_url, $hdrs, $content);
my $uasend = new LWP::UserAgent;
my $resp = $uasend-> request($reqest);
The response I get back is:
<h3>Exception encountered.</h3><pre>Form post has no value for key "info".
Form values are: {}
If I create an HTML doc with a form it finds the data. Is there something
special I need to do to get a hidden form field?
Thanks,
Chris
Re: Novice - How would I add a hidden form field to a LWP::UserAgent call?
Posted by Robert Landrum <rl...@aol.net>.
On Thu, Oct 31, 2002 at 10:28:32AM -0500, Chris Pizzo wrote:
> Hi,
> I'm trying to post data to a server that requires a hidden form field.
>
> This is what I'm doing:
> my $content = "info=somedata";
> my $rec_len = length($content);
> my $send_url = new URI::URL($url);
> my $hdrsend = new HTTP::Headers('Content-length' => $rec_len);
> $hdrsend->header('Content-type' => 'text/html');
>
> my $reqest = new HTTP::Request('POST', $send_url, $hdrs, $content);
> my $uasend = new LWP::UserAgent;
>
> my $resp = $uasend-> request($reqest);
>
I always just did
$req = new HTTP::Request('POST',"http://foo.bar.com/path/");
$req->content("info=somedata");
$ua = new LWP::UserAgent;
$res = $ua->request($req);
print $res->as_string;
Good luck,
Rob
>
> The response I get back is:
> <h3>Exception encountered.</h3><pre>Form post has no value for key "info".
> Form values are: {}
>
> If I create an HTML doc with a form it finds the data. Is there something
> special I need to do to get a hidden form field?
>
> Thanks,
> Chris
>
>
--
Robert Landrum
Systems Programmer