API plaintext exports only chapters list #4218

Closed
opened 2026-02-05 08:16:46 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @andreapx on GitHub (Sep 18, 2023).

Describe the Bug

When I try to export books in a plaintext format with the API, it only exports the chapters list.
This is the URL I use (found in the help): http://bookstack_IP/api/books/BOOK_ID/export/plaintext
If I manually export the book from the web GUI, it works, the txt file has the whole book in it.

Steps to Reproduce

Visit the page http://bookstack_IP/api/books/BOOK_ID/export/plaintext while logged in

Expected Behaviour

In the downloaded file I expect to find the whole book.

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

V22.11.1

Originally created by @andreapx on GitHub (Sep 18, 2023). ### Describe the Bug When I try to export books in a plaintext format with the API, it only exports the chapters list. This is the URL I use (found in the help): http://bookstack_IP/api/books/BOOK_ID/export/plaintext If I manually export the book from the web GUI, it works, the txt file has the whole book in it. ### Steps to Reproduce Visit the page http://bookstack_IP/api/books/BOOK_ID/export/plaintext while logged in ### Expected Behaviour In the downloaded file I expect to find the whole book. ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version V22.11.1
OVERLORD added the 🐛 Bug🏭 Back-End labels 2026-02-05 08:16:46 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Sep 18, 2023):

Thanks for raising @andreapx.

Can confirm issues in this area.
From my testing, UI and API function the same, possibly different on the old version you're using though.
Also seems that pages have their content if within a chapter, but not if on book level.

All due to how limited fetching of required fields before formatting to export.
Assigned to next feature release to fix.

Devnotes

  • Comes down to booktree usage which limits fields in fetch. Maybe split this out to render in tree rather than in page function, chapter/page exports would need to adapt.
  • Output text format is currently wonky, with titles next to previous content, needs fixing too.
  • Add tests to cover export formatting, for both chapters and books. Book tests should cover direct, and nested, pages within the same book.
@ssddanbrown commented on GitHub (Sep 18, 2023): Thanks for raising @andreapx. Can confirm issues in this area. From my testing, UI and API function the same, possibly different on the old version you're using though. Also seems that pages have their content if within a chapter, but not if on book level. All due to how limited fetching of required fields before formatting to export. Assigned to next feature release to fix. ### Devnotes - Comes down to [booktree usage](https://github.com/BookStackApp/BookStack/blob/092b6d6378175720debbcce14d026e8705b5d3cc/app/Entities/Tools/ExportFormatter.php#L336) which [limits fields](https://github.com/BookStackApp/BookStack/blob/2a6533157397a3a3d948f724f48b1f733bc7601f/app/Entities/Tools/BookContents.php#L91) in fetch. Maybe split this out to render in tree rather than in page function, chapter/page exports would need to adapt. - Output text format is currently wonky, with titles next to previous content, needs fixing too. - Add tests to cover export formatting, for both chapters and books. Book tests should cover direct, and nested, pages within the same book.
Author
Owner

@ssddanbrown commented on GitHub (Sep 24, 2023):

This has now been addressed within e9664dc678, and will be part of the next feature release. Thanks again @andreapx for raising.

@ssddanbrown commented on GitHub (Sep 24, 2023): This has now been addressed within e9664dc678f3ffea8d878c984f7ddc284f0189f8, and will be part of the next feature release. Thanks again @andreapx for raising.
Author
Owner

@andreapx commented on GitHub (Sep 24, 2023):

Thanks again @andreapx for raising.

Thanks to me for raising it??? Thanks to you all for the software and the fixes!!!

@andreapx commented on GitHub (Sep 24, 2023): > Thanks again @andreapx for raising. Thanks to me for raising it??? Thanks to you all for the software and the fixes!!!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#4218