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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058192]
Tux looks up his status to find being an Abbot
[choroba]: pm-cb-g now shows the number of unread messages, commit on its way to github
[Tux]: choroba any plans for highlight patterns?
[choroba]: Tux feel free to submit a pull request :-)
[choroba]: I like the idea, but currently I only have time for small changes
[choroba]: but it should be a bit better in two weeks
[Tux]: time also lacks on this side to do more than tiny changes
[Tux]: running on a just pull'd pm-cb-g

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (13)
As of 2017-09-20 16:04 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (237 votes). Check out past polls.