Jessarah FL has asked for the wisdom of the Perl Monks concerning the following question:
I would like to do the same but using LWP::UserAgent. I had tried different ways to call it, here is one:curl -D- -u myUsr:myPwd -X PUT --data '{ "update": { "comment": [ {"ad +d":{"body":"new comment via rest"} } ] } }' -H "Content-Type: applica +tion/json" 'http://myjira:8080/rest/api/2/issue/TSP-3'
but I keep getting: "405 Method Not Allowed at ..."local $ua, $key, %form, $response, $responseTxt; local %req; $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->agent("my trigger"); local $usr="myUsr"; local $pwd="myPwd"; local $reqUri="http://myjira:8080/rest/api/2/issue/TSP-3"; local $data='{ "update": { "comment": [ {"add":{"body":"new commen +t via LWP rest"} } ] } }'; $req{'json'} = $data; my $response = $ua->post( $reqUri, \%req, Authorization => 'Basic +' . encode_base64($usr . ':' . $pwd),'Content-Type'=>'application/jso +n'); if ($response->is_success) { $responseTxt=$response->decoded_content; print "\nResponse:\n$responseTxt\n"; } else { die $response->status_line; }
Thanks for your enlightenment,
Jessica
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: curl request using LWP::UserAgent
by Corion (Patriarch) on Oct 14, 2013 at 12:57 UTC | |
|
Re: curl request using LWP::UserAgent
by Jessarah FL (Novice) on Oct 14, 2013 at 14:22 UTC |