Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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 drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2015-08-04 22:25 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (75 votes), past polls