How to make a HTTP PUT request using LWP?

Steve picture Steve · Dec 11, 2011 · Viewed 9.4k times · Source

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);

Answer

gangabass picture gangabass · Dec 11, 2011

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);