Bug 40970 - REST API: Searching /biblios with JSON 'q' parameter fails with SQL error
Summary: REST API: Searching /biblios with JSON 'q' parameter fails with SQL error
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: 25.05
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-08 03:11 UTC by Adrian
Modified: 2025-10-10 08:28 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian 2025-10-08 03:11:02 UTC
I was checking out the KOHA REST API and I tried using the query parameters in /api/v1/biblios by:

1. Authenticate to the REST API.

2. Send a GET request to /api/v1/biblios with a JSON query parameter like q=[["title", "like", "%Abstract%"]].

This results in a 500 server error:

HTTP error: 500 Server Error: Internal Server Error for url: api/v1/biblios?_page=1&_per_page=5&q=%5B%5B%22title%22%2C+%22like%22%2C+%22%25Abstract%25%22%5D%5D
Response: {"errors":[{"message":"Internal Server Error.","path":"\/"}],"status":500}


Looking at the api error logs I have these:

[2025/10/08 10:21:38] [ERROR] 'true' expected, at character offset 0 (before "title:python") at /usr/share/koha/lib/Koha/REST/Plugin/Objects.pm line 242.
 Mojolicious::Plugin::DefaultHelpers::_development /usr/share/perl5/Mojolicious/Plugin/DefaultHelpers.pm (94)
[2025/10/08 10:23:19] [ERROR] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'q' in 'where clause' at /usr/share/perl5/Data/Page.pm line 49
 Mojolicious::Plugin::DefaultHelpers::_development /usr/share/perl5/Mojolicious/Plugin/DefaultHelpers.pm (94)
[2025/10/08 10:29:34] [ERROR] 'true' expected, at character offset 0 (before "title:Abstract") at /usr/share/koha/lib/Koha/REST/Plugin/Objects.pm line 242.
 Mojolicious::Plugin::DefaultHelpers::_development /usr/share/perl5/Mojolicious/Plugin/DefaultHelpers.pm (94)
[2025/10/08 10:42:07] [ERROR] 'true' expected, at character offset 0 (before "title:Abstract") at /usr/share/koha/lib/Koha/REST/Plugin/Objects.pm line 242.
 Mojolicious::Plugin::DefaultHelpers::_development /usr/share/perl5/Mojolicious/Plugin/DefaultHelpers.pm (94)
[2025/10/08 10:46:25] [ERROR] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column '%Abstract%' in 'where clause' at /usr/share/perl5/Data/Page.pm line 49
 Mojolicious::Plugin::DefaultHelpers::_development /usr/share/perl5/Mojolicious/Plugin/DefaultHelpers.pm (94)


I could use the other parameters like _page and _per_page but when I use q it just crashes. Any help would be nice.
Comment 1 Jonathan Druart 2025-10-10 08:25:10 UTC
The correct syntax is:
  q=[{"title":{"like":"%Abstract%"}}]
Comment 2 Jonathan Druart 2025-10-10 08:28:12 UTC
You will find more info there https://api.koha-community.org/