Skip to content

API updating book_id on chapter not working #4272

@awmol

Description

@awmol

Describe the Bug

Updating book_id on a chapter through API does not change the book_id.

No issue updating other data on a chapter through the api like name, description and tags.
No issue creating a chapter with a specifik book_id through the API.

Steps to Reproduce

Trying to change chapter book_id from 4 to 5, tried several different body syntaxes:

curl --request PUT --url https://bookstack.domain/api/chapters/1232 --header 'Authorization: Token xxxxx' -H 'Content-Type: application/json' -d '{"book_id":"5"}'
curl --request PUT --url https://bookstack.domain/api/chapters/1232 --header 'Authorization: Token xxxxx' -H 'Content-Type: application/json' -d '{book_id:5}'
curl --request PUT --url https://bookstack.domain/api/chapters/1232 --header 'Authorization: Token xxxxx' -H 'Content-Type: application/json' -d '{'book_id':'5'}'
curl --request PUT --url https://bookstack.domain/api/chapters/1232 --header 'Authorization: Token xxxxx' -H 'Content-Type: application/json' -d '{'book_id':5}'
curl --request PUT --url https://bookstack.domain/api/chapters/1232 --header 'Authorization: Token xxxxx' -H 'Content-Type: application/json' -d '{"book_id":5}'

Expected Behaviour

expected a result like:

{"id":1232,"book_id":5,"slug":"test1","name":"test1","description":"test move chapter","priority":277,"created_at":"2023-05-25T13:39:51.000000Z","updated_at":"2023-05-26T08:36:05.000000Z","created_by":6,"updated_by":6,"owned_by":6,"book_slug":"testbook2"}

But get a result like:

{"id":1232,"book_id":4,"slug":"test1","name":"test1","description":"test move chapter","priority":277,"created_at":"2023-05-25T13:39:51.000000Z","updated_at":"2023-05-26T08:36:05.000000Z","created_by":6,"updated_by":6,"owned_by":6,"book_slug":"testbook1"}

Screenshots or Additional Context

No response

Browser Details

curl

Exact BookStack Version

v23.05.1

PHP Version

No response

Hosting Environment

Debian 11, PHP 8.2.6, Nginx +php-fpm

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions