BuildJuniorBackendAuto-graded
Add lookup and create endpoints to a book API
The catalogue API can only list books. Add the endpoints to read one book and to add a new one, with validation and JSON errors.A small Spring Boot API serves a book catalogue, and today it can only list the books. The website team needs two more endpoints: one that returns a single book by its id, and one that adds a new book. The brief gives the exact rules: which status code each case returns, what makes a book valid, and the JSON shape of each error. A test class already checks some of these rules with one command. The rest you check yourself against the brief.35 min
java, spring-boot, maven
You're done when
GET /api/books/{id}returns 200 and the book for an id that exists.GET /api/books/{id}returns 404 and{"error": "book <id> not found"}for an id that does not exist.POST /api/bookswith a valid book returns 201 and the new book with its new id.- The
Locationheader of a created book ends with/api/books/{id}. - A created book is returned by
GET /api/books/{id}right after. - A missing, empty or blank
titleorauthorreturns 400 with that field inerrors. - Year 1449, year 2101 and a missing year return 400 with
yearinerrors. - Year 1450 and year 2100 are accepted.
- When several fields are invalid,
errorslists every invalid field and no valid one.
What it measures
REST API designReturning the right status code, body and Location header for each case.
Request validationTurning written rules into validation on the request, boundaries included.
Error handlingGiving every error one consistent JSON shape that a client can rely on.
Your environment
Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
35 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo