Delete
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
remove an item with the right response.
Planned topics
DELETE /categories/5removes the item.- Success returns
204 No Contentwith no body. - Missing item:
404is common; some teams return204to keep it idempotent. Choose one and document it. - Deleting something other data depends on should return
409, not break the data. - Use
@ResponseStatus(HttpStatus.NO_CONTENT)orResponseEntity.noContent().
Draft outline details
Demonstration
@DeleteMapping("/{id}")
ResponseEntity<Void> delete(@PathVariable long id) {
service.delete(id);
return ResponseEntity.noContent().build();
}Check your understanding
Does 204 carry a body?
Show answer
No.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.