in reply to POSTing QueryString data using LWP::UserAgent

Does the ASP page expect the parameters passed to it by POST (rather than GET as you are trying)?

Try (based on the HTTP::Request::Common docs):

use HTTP::Request::Common; my $ua = LWP::UserAgent->new; my $res = $ua->request(POST 'http://100.100.100.100/ReceivingPage.asp' +, [username => 'test', password => 'test']);

Replies are listed 'Best First'.
Re: Re: POSTing QueryString data using LWP::UserAgent
by IlyaM (Parson) on Jan 08, 2002 at 18:59 UTC
    It should not work since screamingeagle already uses request content to pass XML document. Thus parameters can't be passed as POST - there is no space for them in HTTP request.

    This raises the question if screamingeagle is correct in his expectation that XML document should be passed as raw content of HTTP request. Maybe it should passed as POST parameter? Otherise if ASP page doesn't want username and password as GET parameters and as cookies then there is just no way to pass them.

    --
    Ilya Martynov (http://martynov.org/)

Re: Re: POSTing QueryString data using LWP::UserAgent
by screamingeagle (Curate) on Jan 09, 2002 at 07:13 UTC
    Hi,
    I did follow your advice , with a little modification, and it worked , as far as passing the username and password; now the problem is that the XML data is not being passed .

    Here's what i did. :
    use HTTP::Request::Common; my $filetoopen = 'tp1.xml'; #XML file name my $ua = new LWP::UserAgent; my $res = $ua->request(GET 'http://2.2.2.2/receive.asp'); if ($res->is_success) { { no strict 'subs'; $res = $ua->request(POST 'http://2.2.2.2/receive.asp', Content +_Type => 'form-data', Content => [ username => test, password => test, init => [$filetoopen,$filetoopen], ]); } ...rest of the code...
    I keep getting an error message saying that the file is empty or invalid (I've confirmed that the file is not empty and it is in the same folder as the Perl file which is executing ) Is there something missing in the POST call ? my second question is whether instead of POSTing the XML data in a file, is it possible to post the XML data contained in a scalar variable ?
      Hi,
      I finally found the solution to my problem.Just thought that I'd share it with others...Here's how u post multipart/form-data using HTTP::Request::Common, without having to create a file containing the data (submitting the content directly ) :

      use HTTP::Request::Common; my $ua = new LWP::UserAgent; my $res = $ua->request(GET 'http://2.2.2.2/page.asp'); if ($res->is_success) { { no strict 'subs'; $res = $ua->request(POST 'http://2.2.2.2/page.asp', Content_Type => 'form-data', Content => [ username => test, password => test, init => [undef, "filename", content_type => 'text/xml', content => $request_xml,], ] ); } ...
      Hope this helps someone... :)