[Koha-devel] REST API : PUT for partial update

Fridolin SOMERS fridolin.somers at biblibre.com
Thu Mar 21 11:18:25 CET 2024


OK

But currently this means in PUT you need to add in body the required 
fields (even when unchanged) and the fields you want to change.
Missing fields are kept unchanged right ?
So there is no way to blank a field ?

The need was updating patron expiration date.
So maybe better create a dedicated route with only PUT.
Like the one for privacy :
/public/patrons/{patron_id}/guarantors/can_see_charges

We should add some text to wiki :
https://wiki.koha-community.org/wiki/Koha_REST_API_Users_Guide


Le 20/03/2024 à 16:45, Tomas Cohen Arazi a écrit :
> When we decided to implement the RESTful API, we agreed PUT is for 
> 'replacing' resources, and PATCH for updating selected pieces of them.
> 
> I personally never managed to wrap my mind around PATCH and how to 
> validate what tiny bit is allowed to be patched or not. As OpenAPIv2 is 
> not that flexible.
> 
> But I'm sure Jonathan has implemented PATCH on the ERM, and those 
> controllers look exactly the same as those for PUT.
> 
> That said, I think we could just implement PATCH on the spec, pointing 
> to the same controllers (for now) on an as-needed basis.
> 
> Beware validation of combined parameters, etc.
> 
> Good luck!
> 
> El mié, 20 mar 2024 a las 11:03, Fridolin SOMERS via Koha-devel 
> (<koha-devel at lists.koha-community.org 
> <mailto:koha-devel at lists.koha-community.org>>) escribió:
> 
>     Hi,
> 
>     I've tried to use API for a PUT on patron.
> 
>     Looks like I can't do a partial update, I get error on mandatory datas
>     like if it where a POST.
> 
>     I found this discussion :
>     https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23285#c8
>     <https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23285#c8>
> 
>     Is this a bug ?
> 
>     Best regards,
> 
>     -- 
>     Fridolin SOMERS <fridolin.somers at biblibre.com
>     <mailto:fridolin.somers at biblibre.com>>
>     Software and system maintainer 🦄
>     BibLibre, France
>     _______________________________________________
>     Koha-devel mailing list
>     Koha-devel at lists.koha-community.org
>     <mailto:Koha-devel at lists.koha-community.org>
>     https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
>     <https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel>
>     website : https://www.koha-community.org/
>     <https://www.koha-community.org/>
>     git : https://git.koha-community.org/ <https://git.koha-community.org/>
>     bugs : https://bugs.koha-community.org/
>     <https://bugs.koha-community.org/>
> 
> 
> 
> -- 
> Tomás Cohen Arazi
> Theke Solutions (https://theke.io <https://theke.io>)
> ✆ +54 9351 3513384
> GPG: B2F3C15F

-- 
Fridolin SOMERS <fridolin.somers at biblibre.com>
Software and system maintainer 🦄
BibLibre, France


More information about the Koha-devel mailing list