POST /api/v1/books
⚠️
This endpoints requires Administrator permissions. (@token_required)
Description
This endpoint allows developers to insert new books to the database.
Body (raw)
A list of book objects must be sent in the request's body. Each book must be a book object with a unique numeric id field. The field _id is reserved.
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 the value passed in the body isn't a list.
{
"code": "400",
"status": "error",
"message": "A list of books is required"
}If theres a field _id in one of the objects of the request.
{
"code": "400",
"status": "Bad Request",
"message": "field '_id' is reserved",
"invalid book": Book object that caused the error
}If there isn't a field id in one of the objects of the request.
{
"code": "400",
"status": "Bad Request",
"message": "id is required",
"invalid book": Book object that caused the error
}If there is already another book with the given id.
{
"code": "400",
"status": "Bad Request",
"message": "id must be unique",
"invalid book": Book object that caused the error
}If the id given isn't an integer.
{
"code": "400",
"status": "Bad Request",
"message": "id must be numeric",
"invalid book": Book object that caused the error
}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"
}