Hi Ben

The 'request' method of a UserAgent object takes an HTTP::Request object
reference as a parameter. The parameters you've used look like those for
HTTP::Request->new, except that the third parameter should be a reference to an
HTTP::Headers object rather than an anonymous array reference.

The easiest way to do it that looks somethin like what you have is to use the
HTTP::Request::Common methods to build a request in line. It ends up like this



use LWP::UserAgent;
use HTTP::Request::Common;

my $ua = new LWP::UserAgent;
$ua->timeout(300);

my $res = $ua->request(POST 'http://www.abc.com/cgi-bin/test.cgi',
    var1 => 'This is a Test',
    var2 => 'male',
    var3 => '45');




which should do what you want.

Cheers,

Rob



> -----Original Message-----
> From: Ben Goswami [mailto:[EMAIL PROTECTED]]
> Sent: 01 August 2001 17:50
> To: [EMAIL PROTECTED]
> Subject: Http post problem
>
>
> Hi,
> I'm having problem submitting a form post.  Here is the code.  I'm getting
> an error
> ***
> Can't locate object method "method" via package "POST" at
> C:/perl/site/lib/LWP/UserAgent.pm line 163.
> ******
> Code:
>
> my $ua = new LWP::UserAgent;
>  $ua->timeout(300);
>
>   my $res = $ua->request(POST => 'www.abc.com/cgi-bin/test.cgi',
>       [ var1=> 'This is a Test',
>       var2=>'male',
>       var3=> '45' ] );
>       if ($res->is_success) {
> ...
> }
>
> Any idea?
>
> if I construct the request seperately and pass it to ua
> I get an error some thing like
> "Can't clone ... at line ... at message.pm"
>
>

_________________________________________________________________
Rob Dixon                           Phone:  +44(0) 118 925 6185
Senior Design Engineer              Mobile: +44(0) 7909 577297
Siroyan Limited                     Fax:    +44(0) 118 949 7228
200 Brook Drive
Green Park                          E:mail: mailto:[EMAIL PROTECTED]
Reading                             WWW:    www.siroyan.com
Berkshire
RG2 6UB
England



Reply via email to