Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: curl request using LWP::UserAgent

by Jessarah FL (Novice)
on Oct 14, 2013 at 14:22 UTC ( #1058192=note: print w/ replies, xml ) Need Help??

in reply to curl request using LWP::UserAgent

My problem is that I needed to use put method, and for that I needed to use HTTP::Request The following solutions works:

my $uri=$reqUri; local $data='{ "update": { "comment": [ {"add":{"body":"new commen +t via rest and LWP"} } ] } }'; local $ua, $key, %form, $response; $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->agent("citrigger"); my $request = HTTP::Request->new(PUT => $uri); $request->header(Authorization => 'Basic ' . encode_base64($usr . +':' . $pwd)); $request->content_type('application/json'); $request->content($data); $response = $ua->request($request); if ($response->is_success) { $responseTxt=$response->decoded_content; print "\nResponse:\n$responseTxt\n"; } else { die $response->status_line; } return;
regards, Jessica

Comment on Re: curl request using LWP::UserAgent
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058192]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-11-25 11:18 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (674 votes), past polls