Skip to content
Ameen Abozaid
Planned lessonJNR-019-L04

Delete

  • Lesson 4 of 8
  • Junior
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/5 removes the item.
  • Success returns 204 No Content with no body.
  • Missing item: 404 is common; some teams return 204 to 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) or ResponseEntity.noContent().
Draft outline details

Demonstration

java
@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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.