beckmanel has asked for the wisdom of the Perl Monks concerning the following question:
Problem implementing a relatively simple restful client query, that I have already implemented in curl. A request for device information from a cisco ISE server.
Thank You !!#!/usr/bin/perl use warnings; use REST::Client; use LWP::UserAgent; use JSON; use MIME::Base64; use Data::Dumper; $ENV{HTTPS_VERSION} = 3; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; ######################################################## # This works in the shell ######################################################## #curl -k 'https://<myuser>:<mypassword>@<myhost>/webacs/api/v1/data/De +vices' my $host = 'https://<myhost>'; my $user = '<myuser>'; my $pwd = '<mypassword>'; my $client = REST::Client->new(host => $host); my $encoded_auth = encode_base64("$user:$pwd", ''); $client->GET("/webacs/api/v1/data/Devices", {'Authorization' => "Basic $encoded_auth", 'Accept' => 'application/json'}); print 'Response: ' . $client->responseContent() . "\n"; print 'Response status: ' . $client->responseCode() . "\n"; foreach ( $client->responseHeaders() ) { print 'Header: ' . $_ . '=' . $client->responseHeader($_) . "\n"; } __END__ Response: Can't connect to <myhost>:443 LWP::Protocol::https::Socket: SSL connect attempt failed with unknown +errorerror:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert h +andshake failure at /usr/lib/perl5/site_perl/5.10.0/LWP/Protocol/http +.pm line 47. Response status: 500 Header: Content-Type=text/plain Header: Client-Date=Tue, 28 Jun 2016 13:56:58 GMT Header: Client-Warning=Internal response
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Restful Client Query
by morgon (Priest) on Jun 28, 2016 at 21:17 UTC | |
|
Re: Restful Client Query
by perlfan (Parson) on Jun 28, 2016 at 20:08 UTC | |
|
Re: Restful Client Query
by NetWallah (Canon) on Jun 28, 2016 at 18:07 UTC | |
by Anonymous Monk on Jun 28, 2016 at 21:16 UTC | |
|
Re: Restful Client Query
by NetWallah (Canon) on Jun 28, 2016 at 21:39 UTC | |
by perlfan (Parson) on Jun 29, 2016 at 02:32 UTC | |
by Your Mother (Archbishop) on Jun 29, 2016 at 05:19 UTC | |
by perlfan (Parson) on Jun 29, 2016 at 23:28 UTC | |
by Your Mother (Archbishop) on Jun 30, 2016 at 21:00 UTC |