REST API Debug

From Koha Wiki
Jump to navigation Jump to search

Troubleshooting Koha's REST API functionality

Koha currently depends on specific versions of the following 3 perl packages

 Mojolicious 
 JSON::Validator 
 Mojolicious::Plugin::OpenAPI

If you install Koha using the debian packages you should not have any problems
If you install perl packages manually using CPAN, you *may* install incompatible versions of these packages; specifically for 21.11 versions, and older

more info on bug 30194 [1]


Before you start, you can verify that the API is functional

 $ sudo apt update
 $ sudo apt install -y jq curl pmtools
 $ curl -s http://my.koha.instance.net/api/v1/ |  jq .info.title,.swagger
 "Koha REST API"
 "2.0"

If you do not get the results above, try the following steps

Check koha-common is installed ok

 $ dpkg -s koha-common | grep Status
 Status: install ok installed

Check 3 API packages are installed ok

 $ dpkg -s  libmojolicious-perl libjson-validator-perl libmojolicious-plugin-openapi-perl | grep Status
 Status: install ok installed
 Status: install ok installed
 Status: install ok installed

Check 3 API package's path is correct

this is where the Debian package's files are located

 $ pmpath Mojolicious JSON::Validator Mojolicious::Plugin::OpenAPI
 /usr/share/perl5/Mojolicious.pm
 /usr/share/perl5/JSON/Validator.pm
 /usr/share/perl5/Mojolicious/Plugin/OpenAPI.pm

Check 3 API packages are not installed via CPAN

 $ pmpath Mojolicious JSON::Validator Mojolicious::Plugin::OpenAPI | grep '/usr/local/share/perl' | wc -l
 0

If your above result is not 0, consider deleting your CPAN directory (take a backup, caveat emptor, etc)

 $ sudo rm -rf /usr/local/share/perl

Check 3 API package's versions are compatible

the versions required for 22.05 are...

 $ pmvers Mojolicious JSON::Validator Mojolicious::Plugin::OpenAPI
 Mojolicious: 9.22                   (needs to be 9.22 or higher)
 JSON::Validator: 5.08               (needs to be 5.08 or higher)
 Mojolicious::Plugin::OpenAPI: 5.05  (needs to be 5.05)

the versions required for 21.11 and below are...

 $ pmvers Mojolicious JSON::Validator Mojolicious::Plugin::OpenAPI
 Mojolicious: 8.12                   (needs to be 8.12 or higher)
 JSON::Validator: 3.14               (needs to be 3.14 and less than 4.00)
 Mojolicious::Plugin::OpenAPI: 2.16  (needs to be 2.16 and less than 3.00)

Now you have completed these steps, repeat step 1.1 to verify the API again