[Koha] Parsing public reports

Alvaro Cornejo cornejo.alvaro at gmail.com
Wed Jul 8 18:09:02 NZST 2020


I´m trying to parse the results of a report setup as public but are unable
to get the data.
This is the script I'm working on

 use strict;
 use warnings;

 use LWP::UserAgent;
 use HTTP::Request;

 my $ua = new LWP::UserAgent;
 $ua->agent("Perl API Client/1.0");

 my $url = "https://myurl/report?id=53";

 my $request = HTTP::Request->new("GET" => $url);
 my $response = $ua->request($request);
 print "Response::: " . $response . "\n";

 use JSON;
 my $json_obj = JSON->new->utf8->decode($response->content);

 print "JSON OBJ:  " . $json_obj . "\n";
 print $json_obj->{rowCount} . " rows:n";

 foreach my $row(@{$json_obj->{rows}}){
         print $row->{Key} . ":" . $row->{Value} . "n";

My debug print gives me:

Response::: HTTP::Response=HASH(0x564ec7e6cfa8)
JSON OBJ:  ARRAY(0x564ec76dd7f8)
Not a HASH reference at reporte53-2.pl line 23.

Each time I run the script I get different 0X values.

If I call the report through a web browser I get


And if I add &annotated=1 to my report link I get:


What am I missing for parsing the report?



 Stay safe / Cuídate/  Reste sécurisé
*7* Switch off as you go / Apaga lo que no usas /  Débranchez au fur et à
 *q *Recycle always / Recicla siempre / Recyclez toujours
 P Print only if absolutely necessary / Imprime solo si es necesario /
Imprimez seulement si nécessaire

More information about the Koha mailing list