Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-06 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (69 votes), past polls