in reply to Re: Re: HTTP::Request(POST, ...)
in thread HTTP::Request(POST, ...)

When trying to automate any website, always capture what your browser is sending and receiving, and compare that against what you are sending and receiving.

The error message you are giving, HTTP Status 400 - Invalid direct reference to form login pape, sounds like the server is expecting a valid Referrer: header, and you are not sending any. So, maybe try automating the page through WWW::Mechanize, which tries to behave more like a browser. Once you have that working, you can strip down the script to something only using LWP, or keep the script using WWW::Mechanize.

Replies are listed 'Best First'.
Re^4: HTTP::Request(POST, ...)
by Anonymous Monk on Jun 04, 2004 at 19:15 UTC
    Thanks alot, Corion. I use WWW::Mechanize, it makes my life much easy. But I have a problem here: In a page responsed from server, there is a form in which some fields and two buttons are defined like these: --------------------------- <FORM name="frmSaveUser" action='SaveUser" method="post"> ..... <BUTTON class="pbutton" type="button" onclick="validate(document.frmSaveUser)"> Save</BUTTON> <BUTTON class="pbutton" type="button" onclick="history.back()"> Cancel</BUTTON> ....
    </FORM> --------------- I fill fields and call $browser->click_button(number => 1); I got the error: "can't call method "click" on an undefined value at /usr/lib/perl5/site_perl/5.8.0/WWW/Mechanize.pm line 722" On the button defined above, there is a JavaScript funcation defined to check the validation of filled values. Do I do something wrong? or what should I do to make it work? Thanks again Quency

      You will need to understand what the Javascript does, and then program that thing in Perl. There is no Javascript interpreter plus object model for Perl.

      In the documentation of WWW::Mechanize::Shell is some hint as to how you can maybe work around this problem.

      $agent->current_form->push_input( submit => { name => "submit", value +=>"submit" } );

      But most likely, you will have to look at exactly what the Javascript code does. Maybe even $agent->current_form->submit() already works in your case.