Bug 37032

Summary: REST API: Unable to call item info via holds endpoint
Product: Koha Reporter: Emmi Takkinen <emmi.takkinen>
Component: REST APIAssignee: Emmi Takkinen <emmi.takkinen>
Status: Pushed to main --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:
Bug Depends on:    
Bug Blocks: 36135    
Attachments: Bug 37032: Fix typo in holds.yaml
Bug 37032: Fix typo in holds.yaml
Bug 37032: Fix typo in holds.yaml

Description Emmi Takkinen 2024-06-05 05:43:32 UTC
I'm trying to fetch items barcode via holds endpoint with no luck. If I've understood correctly, this should be possible by adding item as embed in /api/v1/swagger/paths/holds.yaml and then adding it to enum option in kohaTable function. However this only leads to following error: 

>Something went wrong when loading the table.
>400: Bad Request. 
>Not in enum list: cancellation_requested, biblio, pickup_library, item.
Documentation for endpoint shows that endpoint should produce item object and Koha::Hold does have relation to item.
Comment 1 Emmi Takkinen 2024-07-19 09:49:46 UTC
It seems there is a typo in holds.yaml. Setting "collectionFormat: csv" is included inside "items" of "x-koha-embed". Fixing this allows me to add and call item as emded. However now some of my API calls fail on 500 error and Mojolicious compalains that "Not a HASH reference at /usr/share/perl5/SQL/Abstract/Classic.pm line 804".
Comment 2 Emmi Takkinen 2024-07-19 10:11:09 UTC
(In reply to Emmi Takkinen from comment #1)
> It seems there is a typo in holds.yaml. Setting "collectionFormat: csv" is
> included inside "items" of "x-koha-embed". Fixing this allows me to add and
> call item as emded. However now some of my API calls fail on 500 error and
> Mojolicious compalains that "Not a HASH reference at
> /usr/share/perl5/SQL/Abstract/Classic.pm line 804".

This doesn't seem to be related to emded problem.
Comment 3 Emmi Takkinen 2024-07-22 05:32:55 UTC
(In reply to Emmi Takkinen from comment #2)
> (In reply to Emmi Takkinen from comment #1)
> > It seems there is a typo in holds.yaml. Setting "collectionFormat: csv" is
> > included inside "items" of "x-koha-embed". Fixing this allows me to add and
> > call item as emded. However now some of my API calls fail on 500 error and
> > Mojolicious compalains that "Not a HASH reference at
> > /usr/share/perl5/SQL/Abstract/Classic.pm line 804".
> 
> This doesn't seem to be related to emded problem.

I mean, fixing this doesn't lead to 500 errors. Those are rather related how I'm building my table with API result. Fixing that typo allows using embed objects again.
Comment 4 Emmi Takkinen 2024-07-22 07:04:14 UTC
Created attachment 169266 [details] [review]
Bug 37032: Fix typo in holds.yaml

There is a typo in holds.yaml which prevents
fetching item as embeded object. Option
"collectionFormat" should be under "x-koha-embed",
not "items" array.

To test prove t/db_dependent/api/v1/holds.t.

Sponsored-by: Koha-Suomi Oy
Comment 5 Emmi Takkinen 2024-07-22 07:07:27 UTC
I'm unsure what's proper testing method for this (other than running tests for holds.t). Please feel free to point out what else should be tested and I will adjust test plan accordingly.
Comment 6 Emmi Takkinen 2024-08-08 05:31:46 UTC
Setting importance as normal since this prevents using endpoint with its full potential.
Comment 7 David Nind 2024-08-17 09:13:41 UTC
Created attachment 170463 [details] [review]
Bug 37032: Fix typo in holds.yaml

There is a typo in holds.yaml which prevents
fetching item as embeded object. Option
"collectionFormat" should be under "x-koha-embed",
not "items" array.

To test prove t/db_dependent/api/v1/holds.t.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: David Nind <david@davidnind.com>
Comment 8 Martin Renvoize (ashimema) 2024-08-21 08:15:58 UTC
Created attachment 170532 [details] [review]
Bug 37032: Fix typo in holds.yaml

There is a typo in holds.yaml which prevents
fetching item as embeded object. Option
"collectionFormat" should be under "x-koha-embed",
not "items" array.

To test prove t/db_dependent/api/v1/holds.t.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize (ashimema) 2024-08-21 08:16:14 UTC
Ooops, thanks Emmi
Comment 10 Katrin Fischer 2024-08-21 17:15:21 UTC
Pushed for 24.11!

Well done everyone, thank you!