PerlMonger79 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use warnings; use LWP::UserAgent; require HTTP::Cookies; my $ua = new LWP::UserAgent; my $cookie_jar = HTTP::Cookies->new( file => 'cookies_lwp.txt', autosa +ve => 1, ignore_discard => 1 ); # A cookie file is needed to store th +e security keys. $ua->cookie_jar($cookie_jar); $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; $ua->default_header( "Accept" =>"application/json" ); $ua->default_header( "Content-Type" => "application/json"); my $netloc="host"; my $realm="realm name"; my $user="username"; my $pass="password"; $ua->credentials( $netloc, $realm, $user, $pass); $ua->ssl_opts( verify_hostname => 0, SSL_verify_mode => 0x00); my $req = new HTTP::Request('GET','https://host/api/v2/devices/00:04:5 +6:22:51:32/performance/?start_time=2022-02-15T10:00:00&stop_time=2022 +-02-16T10:00:00'); my $res = $ua->request($req); print $res->code, "\n"; print $res->message; use Data::Dumper;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl and API
by talexb (Chancellor) on Feb 21, 2022 at 05:34 UTC |