Contacts
Sales: 603-546-6751
Email: sales@cairnapps.com

General:

Services:

Resources:

Get report example - Perl

The following is a working example in Perl:


     #!/usr/bin/perl
     use strict;
     use LWP::UserAgent;
     use Data::Dumper;
     use JSON;
     use Date::Simple;
     use URI::Encode qw(uri_decode uri_encode );

     ############ Config ############

     my $username = 'tobeissued;
     my $password = 'tobeissued';

     ################################

     my $destination;
     ################### Hand shake ####################

     my %fields = (
          command   => 'cmdBoxTWebAPIHandShake',
          username  => "$username",
          password  => "$password" );
     my @args = ();

     foreach my $key ( keys %fields ) {
          my $value = uri_encode( $fields{ $key } );
          push @args, "$key=$value";
     }

     my $queryString = join('&', @args );


     $destination     = "https://www.dumpster.software/controller.html?$queryString";
     my $ua = LWP::UserAgent->new;
     my $response =  $ua->request(HTTP::Request->new(GET => $destination));


     my $json = JSON->new();
     my $obj = $json->decode( $response->content );

     unless ( $obj->{ status } == 200) {
          print Data::Dumper->Dump([ $obj ]);
          exit;
     }
     #####################  Get Report ##############
     #Extract Key from the resulting JSON for use in the Get Reports
     my $key = $obj->{ key };

     %fields = (
          command             => 'cmdBoxTWebAPIGetReports',
          username            => "$username",
          key                 => "$key",
          reportName          => 'ACCT: Transaction Summary',
          startDate           => '2021-03-01',
          endDate             => '2021-03-31' );

     @args = ();

     foreach my $key ( keys %fields ) {
          my $value = uri_encode( $fields{ $key } );
          push @args, "$key=$value";
     }

     $queryString = join('&', @args );

     $destination = "https://www.dumpster.software/controller.html?$queryString";
     $response =  $ua->request(HTTP::Request->new(GET => $destination));

     $obj = $json->decode( $response->content );

     unless ( $obj->{ status } == 200) {
          print Data::Dumper->Dump([ $obj ]);
          exit;
     }

     my @result =  @{ $obj->{ output }} ;