API — Book Genre Operations
Each book must have a specific genre it belongs to. The following API operations are management endpoints to manage book genre items.
To demonstrate this let’s start by retrieving all existing book genres.
Remember to make use of the access_token
obtained in the previous sections.
Get all Book Genres
This request will retrieve all the existing book genres from the system. If no book genres exist
then the response will be an empty array: [ ]
-
Perform a
GET
request: -
This should provide a response like:
-
The response above shows the first three items, the rest are omitted for brevity.
Create a Book Genre
This endpoint provides functionality to create a new book genre item. It is considered a system operation and thus require elevated user permissions to execute.
The combination of the genre
and subGenre
items must be unique, otherwise an exception
will be thrown.
-
Perform a
POST
request: -
This should provide a response like:
-
The response above shows the newly created book genre. Take note of the
bookGenreID
value and copy it. In the subsequent sections it will be used as a path parameter.
Get Book Genre by BookGenreID
This endpoint provides functionality to retrieve a specific book genre item by making use of the
bookGenreID
value as the lookup key. The value is passed along to the back-end application by
the means of a path parameter value.
-
Perform a
GET
request: -
This should provide a response like:
-
The response above shows the newly created book genre. Take note of the
bookGenreID
value and copy it. In the subsequent sections it will be used as a path parameter.
Update Book Genre by BookGenreID
This endpoint provides functionality to update an existing book genre item by making use of the
bookGenreID
value as the lookup key. The value is passed along to the back-end application by
the means of a path parameter value.
The request body contents contain the updated values to be applied to the existing item.
-
Perform a
PUT
request: -
There is no response body, and the HTTP status code is
HTTP 204 No Content
-
You can run the Get Book Genre by BookGenreID request again to see the difference. The response will show the updated
subGenre
value which changed fromProgramming
toProgrammings
.
Delete Book Genre by BookGenreID
This endpoint provides functionality to delete an existing book genre item by making use of the
bookGenreID
value as the lookup key. The value is passed along to the back-end application by
the means of a path parameter value.
-
Perform a
DELETE
request: -
There is no response body, and the HTTP status code is
HTTP 204 No Content
-
You can run the Get Book Genre by BookGenreID request again to see the difference. The response will return with the HTTP status code of
HTTP 404 Not Found
as the item has been deleted. The response body will also indicate what went wrong as can be seen below:
Summary
Endpoints covered in this guide are as follows:
GET /genres/books
- Retrieves all book genres found in the system
POST /genres/books
- Create a new book genre
GET /genres/books/<bookGenreID>
- Retrieves a single book genre by making use of a
bookGenreID
value
- Retrieves a single book genre by making use of a
PUT /genres/books/<bookGenreID>
- Updates an existing book genre item by making use of a
bookGenreID
value
- Updates an existing book genre item by making use of a
DELETE /genres/books/<bookGenreID>
- Delete an existing book genre item by making use of a
bookGenreID
value
- Delete an existing book genre item by making use of a