0Pricing
Java Academy · Lesson

RFC 7807 Problem Details and Consistent Error Responses

Return structured error payloads conforming to RFC 7807 using Spring 6's ProblemDetail.

What Is RFC 7807?

RFC 7807 "Problem Details for HTTP APIs" defines a standard JSON format for error responses. It avoids custom error formats per API and gives clients a predictable structure to parse.

RFC 7807 Fields

Standard fields: type (URI identifying the problem), title (human-readable summary), status (HTTP status code), detail (specific explanation), instance (URI of the specific occurrence).

{
  "type": "https://api.example.com/errors/not-found",
  "title": "Resource Not Found",
  "status": 404,
  "detail": "User with id 42 does not exist.",
  "instance": "/api/users/42"
}

All lessons in this course

  1. Bean Validation: @NotNull, @Size, @Pattern
  2. Custom Constraint Annotations
  3. Global Exception Handling with @ControllerAdvice
  4. RFC 7807 Problem Details and Consistent Error Responses
← Back to Java Academy