Bug 39212

Summary: Error when attempting to edit a booking
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: CirculationAssignee: Lucas Gass (lukeg) <lucas>
Status: Pushed to main --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle.m.hall, martin.renvoize, pedro.amorim, tomascohen
Version: MainKeywords: rel_24_11_candidate
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Trivial patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:
Attachments: Bug 39212: Explicitly set the contentType to JSON
Bug 39212: Explicitly set the contentType to JSON
Bug 39212: Explicitly set the contentType to JSON
Bug 39212: Explicitly set the contentType to JSON

Description Lucas Gass (lukeg) 2025-02-27 21:46:44 UTC
To recreate:

1. Make an item or item type 'Bookable'
2. Place a booking for that item 
3. Go the 'Bookings' tab for that item.
4. Edit the booking
5. Submit the edit request and see at the top of the modal "Failure"

I also see something like this in the console:

PUT http://localhost:8081/api/v1/bookings/10 400 error
Comment 1 Lucas Gass (lukeg) 2025-02-27 22:33:30 UTC
It looks like the ajax request when doing PUT isn't assuming JSON.
Comment 2 Lucas Gass (lukeg) 2025-02-27 22:36:08 UTC
Created attachment 178811 [details] [review]
Bug 39212: Explicitly set the contentType to JSON

To test:
1. Make an item or item type 'Bookable'
2. Place a booking for that item
3. Go the 'Bookings' tab for that item.
4. Edit the booking
5. Submit the edit request and see at the top of the modal "Failure"
6. APPLY PATCH
7. Try editing bookings, now it should work.
Comment 3 Lucas Gass (lukeg) 2025-02-27 22:38:00 UTC
Created attachment 178812 [details] [review]
Bug 39212: Explicitly set the contentType to JSON

To test:
1. Make an item or item type 'Bookable'
2. Place a booking for that item
3. Go the 'Bookings' tab for that item.
4. Edit the booking
5. Submit the edit request and see at the top of the modal "Failure"
6. APPLY PATCH
7. Try editing bookings, now it should work.
Comment 4 Lucas Gass (lukeg) 2025-02-27 23:04:43 UTC
I don't really know why I need this because in `api/v1/swagger/paths/bookings.yaml` is says:


  consumes:
    - application/json
  produces:
    - application/json
Comment 5 Andrew Fuerste-Henry 2025-02-28 20:20:59 UTC
Created attachment 178871 [details] [review]
Bug 39212: Explicitly set the contentType to JSON

To test:
1. Make an item or item type 'Bookable'
2. Place a booking for that item
3. Go the 'Bookings' tab for that item.
4. Edit the booking
5. Submit the edit request and see at the top of the modal "Failure"
6. APPLY PATCH
7. Try editing bookings, now it should work.

Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Comment 6 Martin Renvoize (ashimema) 2025-03-04 16:41:57 UTC
Created attachment 178930 [details] [review]
Bug 39212: Explicitly set the contentType to JSON

To test:
1. Make an item or item type 'Bookable'
2. Place a booking for that item
3. Go the 'Bookings' tab for that item.
4. Edit the booking
5. Submit the edit request and see at the top of the modal "Failure"
6. APPLY PATCH
7. Try editing bookings, now it should work.

Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize (ashimema) 2025-03-04 16:42:50 UTC
Thanks for fixing this Lucas.. it's odd, I would have expected to notice this a lot earlier.. it feels like either this is browser specific or a jQuery change.. either way, being explicit about contentType is a positive change.

Passing QA
Comment 8 Katrin Fischer 2025-03-07 14:43:06 UTC
Pushed for 25.05!

Well done everyone, thank you!
Comment 9 Pedro Amorim 2025-05-29 15:02:40 UTC
Backport please.