csuresh01 has asked for the wisdom of the Perl Monks concerning the following question:

I was updating a HTML page using LWP,HTTP Request it was working fine when I am testing. But when i am trying this with the orginal code it was not working.

Same coding used in both the cases.

Can any one pls let me know how to update.

$postStr ="ettablenr=2&etcell2x1=Task&etcell2x2=1&etcell2x3=2&etcell24 +=3&etcell2x5=High&etrows=2&etsave=Save table"; $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(POST =>$PATH . @TaskName[1]. '#edittable2 +'); $req->content_type('application/x-www-form-urlencoded'); $req->content_type($postStr); my $res = $ua->request($req); print $res->as_string;

Replies are listed 'Best First'.
Re: LWP : Post Problem
by borisz (Canon) on Aug 30, 2004 at 10:25 UTC
    you set the content_type twice. Try it with
    $req->content($postStr);
    instead. Even better use
    use HTTP::Request::Common; my $res = $ua->request(POST =>$url, [ ettablenr => 2, etcell2x1=>'Task', ... ]);
    Boris
Re: LWP : Post Problem
by Anonymous Monk on Aug 31, 2004 at 15:39 UTC
    Still the problem continues. When I tries to update like this its working fine.

    use LWP::UserAgent; use HTTP::Request; use HTTP::Response; use URI::Heuristic; use HTTP::Request::Common; $ua = LWP::UserAgent->new; my $res = $ua->request(POST $url, Content_Type=>'form-data', Content =>[ettablenr => '2',etcell2x1=>'Task',etcell2x2=>'1',etcell2 +x3=>'2',etcell2x4=>'3',etcell2x5=>'High',etcell2x6=>'CSS',etcell2x7=> +'CCCC',etcell2x8=>'Twiki Updation',etcell3x1=>'Task',etcell3x2=>'4',e +tcell3x3=>'5',etcell3x4=>'6',etcell3x5=>'High',etcell3x6=>'DSS',etcel +l3x7=>'DDDD',etcell3x8=>'Twiki CSV',etrows=>'3',etsave=>'Save table'] +);

    When I tries to put the Values into a Variable and then its was not working

    $postStr ="ettablenr => '2',etcell2x1=>'Task',etcell2x2=>'1',etcell2x3=>'2',etcell2x4=>'3', +etcell2x5=>'High',etcell2x6=>'CSS',etcell2x7=>'CCCC',etcell2x8=>'Twik +i Updation',etcell3x1=>'Task',etcell3x2=>'4',etcell3x3=>'5',etcell3x4 +=>'6',etcell3x5=>'High',etcell3x6=>'DSS',etcell3x7=>'DDDD',etcell3x8= +>'Twiki CSV',etrows=>'3',etsave=>'Save table'"; $ua = LWP::UserAgent->new; my $res = $ua->request(POST $url, Content_Type=>'form-data', Content =>[$postStr]);


    Can u pls let me know what happening when i am trying to update with a String
      The problem is that in the first example your Content is a reference to a array with all your content values.
      But in the second example your content is a reference to a array with only _ONE_ entry. anoteher way is to put your content data into a array or hash. Here is a example with a hash:
      my %data = ( ettablenr => '2', etcell2x1 => 'Task', etcell2x2 => '1', etcell2x3 => '2', etcell2x4 => '3', etcell2x5 => 'High', etcell2x6 => 'CSS', etcell2x7 => 'CCCC', etcell2x8 => 'Twiki Updation', etcell3x1 => 'Task', etcell3x2 => '4', etcell3x3 => '5', etcell3x4 => '6', etcell3x5 => 'High', etcell3x6 => 'DSS', etcell3x7 => 'DDDD', etcell3x8 => 'Twiki CSV', etrows => '3', etsave => 'Save table' ); # you change something with $data{etrows} = 4; my $res = $ua->request(POST $url, Content_Type=>'form-data', Content =>[ %data ] );
      Boris