/api/v1/books/id

PUT /api/v1/books/<str:id>

⚠️

This endpoints requires Administrator permissions. (@token_required)

Description

This endpoint allows developers to update a book already in the database. The "id" and "_id" values cannot be replaced.

Parameters

There is only one parameter available and it's required to this endpoint return the correct response.

  • id: Book ID to select the book is going to be updated. (eg: 2)

Body (raw)

A json object containing the information that will replace the existing book. It cannot contain "id" nor "_id" values.


Request

Response

The response will show if the books were added successfully.

  {
"status": "Success",
"message": "Books added successfully"
}

Bad Request (400)

If the token is missing in the request header.

{
    "code": "400",
    "status": "Bad Request",
    "message": "Token header is required"
}

If a field id is passed in the request.

{
    "code": "400",
    "status": "Bad Request",
    "message": "Changing the id of the book is not allowed"
}

If a field _id is passed in the request.

{
    "code": "400",
    "status": "Bad Request",
    "message": "field '_id' is reserved"
}

Unauthorized (401)

If the Administrator token is expired.

{
    "code": "401",
    "status": "Unauthorized",
    "message": "Token expired"
}

If the Administrator token is incorrect.

{
    "code": "401",
    "status": "Unauthorized",
    "message": "Token incorrect"
}