Bug 31796 - Add PUT endpoint for Authorities
Summary: Add PUT endpoint for Authorities
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low new feature (vote)
Assignee: Agustín Moyano
QA Contact:
URL:
Keywords:
Depends on: 31795
Blocks: 31790 32735
  Show dependency treegraph
 
Reported: 2022-10-14 14:35 UTC by Nick Clemens
Modified: 2023-12-28 20:43 UTC (History)
4 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00


Attachments
Bug 31796: Add REST endpoint to modify an authority (12.12 KB, patch)
2022-12-20 21:00 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31796: Add REST endpoint to modify an authority (11.13 KB, patch)
2022-12-20 22:53 UTC, David Nind
Details | Diff | Splinter Review
Bug 31796: Add REST endpoint to modify an authority (8.99 KB, patch)
2023-04-14 18:28 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 31796: Add REST endpoint to modify an authority (9.04 KB, patch)
2023-04-28 13:20 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2022-10-14 14:35:59 UTC

    
Comment 1 Agustín Moyano 2022-12-20 21:00:11 UTC Comment hidden (obsolete)
Comment 2 David Nind 2022-12-20 22:53:41 UTC
Created attachment 144752 [details] [review]
Bug 31796: Add REST endpoint to modify an authority

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Pick an authority to modify, and modify it's marc record
4. Make a PUT request to /api/v1/authorities/:authid with one of the following content type header
  - application/json
  - application/marcxml+xml
  - application/marc-in-json
  - application/marc
5. If content type is other than 'application/json' place the following header in the request 'x-authority-type: <auth type>'
5. Check that the authority was modified
6. Sign off

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2022-12-20 22:59:55 UTC
Testing notes (using KTD) - similar to bug 31795 I used Postman to test with these details:

1. Changed to a PUT with the URL as http://127.0.0.1:8081/api/v1/authorities/973 (any existing authority will work)
2. Body: changed to 'raw', pasted in the XML with the 150 field to change the heading[1], and changed the type to XML
3. Added Headers: 
   . x-authority-type: used TOPIC_TERM as the value
   . Content-Type: used application/marcxml+xml as the value
4. For authorization, added the Basic Auth type with koha as the username and password

The heading in 150 was changed!

[1] XML used to change the heading:

<?xml version="1.0" encoding="UTF-8"?>
<record
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
    xmlns="http://www.loc.gov/MARC21/slim">
  <datafield tag="150" ind1=" " ind2=" ">
    <subfield code="a">This is a new heading title</subfield>
  </datafield>
</record>
Comment 4 David Nind 2023-04-05 20:11:06 UTC
The patch no longer applies (was trying to test bug 32735):

git bz apply 31796

Bug 31796 - REST API: PUT endpoint for Authorities

144752 - Bug 31796: Add REST endpoint to modify an authority

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 31796: Add REST endpoint to modify an authority
error: sha1 information is lacking or useless (Koha/REST/V1/Authorities.pm).
error: could not build fake ancestor
Patch failed at 0001 Bug 31796: Add REST endpoint to modify an authority
Comment 5 Agustín Moyano 2023-04-14 18:28:42 UTC
Created attachment 149702 [details] [review]
Bug 31796: Add REST endpoint to modify an authority

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Pick an authority to modify, and modify it's marc record
4. Make a PUT request to /api/v1/authorities/:authid with one of the following content type header
  - application/json
  - application/marcxml+xml
  - application/marc-in-json
  - application/marc
5. If content type is other than 'application/json' place the following header in the request 'x-authority-type: <auth type>'
5. Check that the authority was modified
6. Sign off

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 Nick Clemens 2023-04-28 13:20:15 UTC
Created attachment 150374 [details] [review]
Bug 31796: Add REST endpoint to modify an authority

To test:
1. Apply patch
2. Set RESTBasicAuth preference to true
3. Pick an authority to modify, and modify it's marc record
4. Make a PUT request to /api/v1/authorities/:authid with one of the following content type header
  - application/json
  - application/marcxml+xml
  - application/marc-in-json
  - application/marc
5. If content type is other than 'application/json' place the following header in the request 'x-authority-type: <auth type>'
5. Check that the authority was modified
6. Sign off

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 7 Tomás Cohen Arazi 2023-05-05 15:14:39 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 8 Martin Renvoize 2023-05-12 14:59:13 UTC
Enhancement, won't be backporting as the tree above has also not been ported.

If you're desperate for this in 22.11 let me know and we can look at backporting the whole tree as one set.