I am using an existing framework to automate some apis. This structure uses the HTTP :: Request module. I need to write a script to upload a file. I can do this using the HTTP :: Request :: Common module, but NOT with the Http :: Request module. But I need to use Http :: Request only for this. Below code snippets:
Using HTTP :: Request :: Common \ This Works
$request = POST $uri, Content_Type => 'multipart/form-data', Content => [ file => [$file] ] ; my $results=$ua->request($request ) ;
Using HTTP :: Request \ This does not work, I get an error
my $req = HTTP::Request->new("POST", $uri ); $req->header(Content_Type => "form-data"); $req->content('file=>$file'); my $res = $ua->request($req);
Can someone please tell me what I am doing wrong in the above code?
source share