JSON parsing problem with KOha 24.05
Hi All We are still preparing the migration from 19.11 to 24.05 We are testing some parsing some reports through JSON that work in 19.11 but does not in 24.05. The snippet where we think there is a problem is: In 19.11 this works fine. We get the values and we can do the magic we need 36 my $url30 = "https://XXX/cgi-bin/koha/svc/report?id=87"; 37 my $request30 = HTTP::Request->new("GET" => $url30); 38 my $response30 = $ua->request($request30); 39 40 use JSON; 41 my $json_obj30 = JSON->new->utf8->decode($response30->content); 42 43 # Gives the number of rows (30 days) in the array 44 my $row_num30 = scalar(@{$json_obj30}); 45 print scalar(@{$json_obj30}), " rows30\n"; However, the same code in 24.05 give us the following error: acornejo@Koha24:~/perl$ sudo perl TablaEventos.pl Ejecutando TablaEventos-84 malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "Can't connect to bib...") at TablaEventos.pl line 41. acornejo@Koha24:~/perl$ Line 41 correspond to: 41 my $json_obj30 = JSON->new->utf8->decode($response30->content); Any idea what could be wrong? Regards Alvaro |----------------------------------------------------------------------------------------| Stay safe / Cuídate/ Reste sécurisé *7* Switch off as you go / Apaga lo que no usas / Débranchez au fur et à mesure. *q *Recycle always / Recicla siempre / Recyclez toujours P Print only if absolutely necessary / Imprime solo si es necesario / Imprimez seulement si nécessaire
Hi, We found the problem. We had to set the report as Public and use OPAC base url since we are running the report parsing from the CLI. Regards Alvaro |----------------------------------------------------------------------------------------| Stay safe / Cuídate/ Reste sécurisé *7* Switch off as you go / Apaga lo que no usas / Débranchez au fur et à mesure. *q *Recycle always / Recicla siempre / Recyclez toujours P Print only if absolutely necessary / Imprime solo si es necesario / Imprimez seulement si nécessaire Le mar. 8 oct. 2024 à 23:57, Alvaro Cornejo <cornejo.alvaro@gmail.com> a écrit :
Hi All
We are still preparing the migration from 19.11 to 24.05
We are testing some parsing some reports through JSON that work in 19.11 but does not in 24.05.
The snippet where we think there is a problem is:
In 19.11 this works fine. We get the values and we can do the magic we need
36 my $url30 = "https://XXX/cgi-bin/koha/svc/report?id=87"; 37 my $request30 = HTTP::Request->new("GET" => $url30); 38 my $response30 = $ua->request($request30); 39 40 use JSON; 41 my $json_obj30 = JSON->new->utf8->decode($response30->content); 42 43 # Gives the number of rows (30 days) in the array 44 my $row_num30 = scalar(@{$json_obj30}); 45 print scalar(@{$json_obj30}), " rows30\n";
However, the same code in 24.05 give us the following error:
acornejo@Koha24:~/perl$ sudo perl TablaEventos.pl
Ejecutando TablaEventos-84 malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "Can't connect to bib...") at TablaEventos.pl line 41. acornejo@Koha24:~/perl$
Line 41 correspond to: 41 my $json_obj30 = JSON->new->utf8->decode($response30->content);
Any idea what could be wrong?
Regards
Alvaro
|----------------------------------------------------------------------------------------| Stay safe / Cuídate/ Reste sécurisé *7* Switch off as you go / Apaga lo que no usas / Débranchez au fur et à mesure. *q *Recycle always / Recicla siempre / Recyclez toujours P Print only if absolutely necessary / Imprime solo si es necesario / Imprimez seulement si nécessaire
Start by examining the value of $response30->content on the both the old and updated systems to see what is actually returned *Joel Coehoorn* Director of Information Technology *York University* Office: 402-363-5603 | jcoehoorn@york.edu | york.edu On Tue, Oct 8, 2024 at 11:58 PM Alvaro Cornejo <cornejo.alvaro@gmail.com> wrote:
Hi All
We are still preparing the migration from 19.11 to 24.05
We are testing some parsing some reports through JSON that work in 19.11 but does not in 24.05.
The snippet where we think there is a problem is:
In 19.11 this works fine. We get the values and we can do the magic we need
36 my $url30 = "https://XXX/cgi-bin/koha/svc/report?id=87"; 37 my $request30 = HTTP::Request->new("GET" => $url30); 38 my $response30 = $ua->request($request30); 39 40 use JSON; 41 my $json_obj30 = JSON->new->utf8->decode($response30->content); 42 43 # Gives the number of rows (30 days) in the array 44 my $row_num30 = scalar(@{$json_obj30}); 45 print scalar(@{$json_obj30}), " rows30\n";
However, the same code in 24.05 give us the following error:
acornejo@Koha24:~/perl$ sudo perl TablaEventos.pl
Ejecutando TablaEventos-84 malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "Can't connect to bib...") at TablaEventos.pl line 41. acornejo@Koha24:~/perl$
Line 41 correspond to: 41 my $json_obj30 = JSON->new->utf8->decode($response30->content);
Any idea what could be wrong?
Regards
Alvaro
|----------------------------------------------------------------------------------------| Stay safe / Cuídate/ Reste sécurisé *7* Switch off as you go / Apaga lo que no usas / Débranchez au fur et à mesure. *q *Recycle always / Recicla siempre / Recyclez toujours P Print only if absolutely necessary / Imprime solo si es necesario / Imprimez seulement si nécessaire _______________________________________________
Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha
participants (2)
-
Alvaro Cornejo -
Coehoorn, Joel