Question

I'm trying to change this request to a HTTP PUT request, any idea how ?

my $request = LWP::UserAgent->new; 
my $response = 
        $request->get($url, "apikey", $apiKey, "requestDate", $requestDate);
Was it helpful?

Solution

You should use HTTP::Request:

use LWP::UserAgent;
use HTTP::Request;

my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new("PUT", $url); 

my $res = $ua->request($req);

OTHER TIPS

As of 6.04, LWP::UserAgent has a put helper, so you can now do:

$ua->put( $url )

PUT is HTTP::Request::Common. You can build the request first and pass it into user agent.

use HTTP::Request::Common;
use LWP;

$agent    = LWP::UserAgent->new;
$request  = HTTP::Request::Common::PUT($url, "apikey", $apiKey, "requestDate", $requestDate); 
$response = $agent->request($request);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top