How do you use the API to create/update a shelf or book with a cover? #5216

Closed
opened 2026-02-05 09:49:07 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @MisterDeee on GitHub (Mar 9, 2025).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

As per the subject, I can create/update using my API wrapper or Postman just fine, everything works as expected. Except cover images. I've gone over the API docs countless times, I made sure to set the request to multipart/form-data. But every time the cover property is null in the response. It's not a user permissions issue, I am the admin and it's my token. Everything returns 200 OK so there's not even error logs to look over. What am I doing wrong?

Exact BookStack Version

v25.02

Log Content

No response

Hosting Environment

Docker container on physical host.

Originally created by @MisterDeee on GitHub (Mar 9, 2025). ### Attempted Debugging - [x] I have read the debugging page ### Searched GitHub Issues - [x] I have searched GitHub for the issue. ### Describe the Scenario As per the subject, I can create/update using my API wrapper or Postman just fine, everything works as expected. Except cover images. I've gone over the API docs countless times, I made sure to set the request to multipart/form-data. But every time the cover property is null in the response. It's not a user permissions issue, I am the admin and it's my token. Everything returns 200 OK so there's not even error logs to look over. What am I doing wrong? ### Exact BookStack Version v25.02 ### Log Content _No response_ ### Hosting Environment Docker container on physical host.
OVERLORD added the 🐕 Support label 2026-02-05 09:49:07 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Mar 9, 2025):

Hi @MisterDeee,
Do you have a screenshot of the postman request? Or an example of the API wrapper you're using?

@ssddanbrown commented on GitHub (Mar 9, 2025): Hi @MisterDeee, Do you have a screenshot of the postman request? Or an example of the API wrapper you're using?
Author
Owner

@MisterDeee commented on GitHub (Mar 9, 2025):

Yes, sorry, should have included that right away.

Image

@MisterDeee commented on GitHub (Mar 9, 2025): Yes, sorry, should have included that right away. ![Image](https://github.com/user-attachments/assets/fa72ebb5-e91a-4cfe-a7fd-8da8469c5430)
Author
Owner

@ssddanbrown commented on GitHub (Mar 9, 2025):

@MisterDeee I think you may be running into a quirk of the API (and PHP in general) which is confusing matters.

Assuming the shown response is for that shown request, then no information is being updated (name not changing, so not just the cover image).
Form data requests will only work with POST requests.
To use for this PUT request, change the HTTP method used to "POST" then add a field to the sent data with name _method and value PUT.

If needed to reference in the future, this is mentioned in the "Request Format" part of the API docs.

I know this is really awkward right now though. I think there have been some recent PHP changes that might improve on this in the future though.

@ssddanbrown commented on GitHub (Mar 9, 2025): @MisterDeee I think you may be running into a quirk of the API (and PHP in general) which is confusing matters. Assuming the shown response is for that shown request, then no information is being updated (name not changing, so not just the cover image). Form data requests will only work with POST requests. To use for this PUT request, change the HTTP method used to "POST" then add a field to the sent data with name `_method` and value `PUT`. If needed to reference in the future, this is mentioned in the "Request Format" part of the API docs. I know this is really awkward right now though. I think there have been some recent PHP changes that might improve on this in the future though.
Author
Owner

@MisterDeee commented on GitHub (Mar 9, 2025):

Wow, I should have read the docs more closely, sorry for that. But as expected, it works now! Thank you so much!
One question, is there a way to use a URL instead of uploading an actual image?
Thank you again for the excellent help!

@MisterDeee commented on GitHub (Mar 9, 2025): Wow, I should have read the docs more closely, sorry for that. But as expected, it works now! Thank you so much! One question, is there a way to use a URL instead of uploading an actual image? Thank you again for the excellent help!
Author
Owner

@ssddanbrown commented on GitHub (Mar 9, 2025):

One question, is there a way to use a URL instead of uploading an actual image?

No, a file is required right now (Downloading from URLs on BookStack server-side starts to get messy when things like SSRF have to be taken into account).

Happy I could help! I'll therefore close this off.

@ssddanbrown commented on GitHub (Mar 9, 2025): > One question, is there a way to use a URL instead of uploading an actual image? No, a file is required right now (Downloading from URLs on BookStack server-side starts to get messy when things like SSRF have to be taken into account). Happy I could help! I'll therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5216