Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 cooling their heels in the Monastery: (12)
As of 2014-07-25 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls