In the short term, it appears I’ve forgotten about the “q” parameter. It takes an unencoded argument, so that’s getting me where I need to go…

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 

From: David Cook <dcook@prosentient.com.au>
Sent: Friday, 12 May 2023 4:47 PM
To: 'Koha Devel' <koha-devel@lists.koha-community.org>
Subject: Issues sending a JSON request body in a GET request to REST API

 

Hi all,

 

With the Koha REST API, there’s “Advanced Matching” which uses a JSON body in a GET request:

 

curl -u koha:koha --request GET 'http://127.0.0.1:8081/api/v1/patrons/' --header "Content-Type: application/json" --data-raw '{ "-or": [ { "surname": { "-like": "Acev%" } }, { "firstname": { "-like": "Hen%" } } ] }'

 

https://wiki.koha-community.org/wiki/Koha_REST_API_Users_Guide#Advanced_Matching

 

While this technically works, we really shouldn’t be sending a JSON request body in a GET request.

 

I’m working on a third-party system, and it’s actually preventing me from sending GET requests with request bodies (since GET requests aren’t supposed to have request bodies), so I can’t actually use the API using that system’s built-ins. I’ll have to code a workaround.

 

At some point, we should replace these GET requests with POSTed search queries I think.

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595