
Cisco Evolved Programmable Network Manager API
Evolved Programmable Network Manager API Documentation

# Using Perl

This Perl script uses LWP::UserAgent. It makes an unverified HTTPS request to NBI resource and print result. To run the script below, you will need to install LWP::Protocol::https from CPAN.

    #!/opt/local/bin/perl -w
    use strict;
    use LWP;
    use LWP::UserAgent;

    my $BASE_URL = "https://my_server/webacs/api/v4";
    my $UN="user";
    my $PW="password";
    my $REST_PATH = "/data/InventoryDetails";

    $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
    my $ua = LWP::UserAgent->new;
    sub fetch ($){
    	my ($url) = @_;
    	my $req = HTTP::Request->new(GET => $BASE_URL.$url);
    	$req->authorization_basic($UN,$PW);
    	return $ua->request($req)->content or die ("Cannot read from ".$BASE_URL.$url);
    }

    my $content = fetch($REST_PATH);
    print ($content);