in reply to Re^3: Post using LWP useragent curl post request to useragent request
in thread Post using LWP useragent curl post request to useragent request
__________________________try 2_______________________________my $request = HTTP::Request::Common::POST( BOX, [ Content_Type => 'form-data', Authorization => "Bearer $token", Content => [ attributes => $c, #encoded json file => [ "$Bin/test.txt" ], #file_path ], ] );
I am pro when comes to Perl but don't know how http post works. Do I have to encode body params while passing. and not sure if LWP::Useragent will fetch the file contain itself given the full file path or not. Can you help me in get this working.sub build_json_request { my ($url) = @_; my $header = ['Authorization' => "Bearer $token", 'Content-Type' = +> 'form-data']; return HTTP::Request->new('POST', $url, $header, {attributes => $c +, file=> [ "$Bin/upload.bak" ],} ); } my $r = build_json_request (ENDPOINT ); my $res = $ua->request($r);
In Section
Seekers of Perl Wisdom