application/problem+json Header

Introduction
application/problem+json is a standardized media type (Content-Type header value) used in HTTP APIs to convey error details in a structured, machine-readable format. It is defined by RFC 7807 (and its successor RFC 9457), which specifies "Problem Details for HTTP APIs."
Purpose:
The primary purpose of application/problem+json is to provide a consistent and extensible way for APIs to communicate error information to clients, beyond just the HTTP status code. This allows clients to better understand the nature of the error and potentially take appropriate actions.
Key Fields in a Problem Details JSON Object:
A typical application/problem+json response includes the following standard fields:
type: A URI reference that identifies the problem type. This can be a URL pointing to a human-readable explanation of the error or a URN.title: A short, human-readable summary of the problem type.status: The HTTP status code generated by the origin server for this occurrence of the problem.detail: A human-readable explanation specific to this occurrence of the problem.instance: A URI reference that identifies the specific occurrence of the problem, useful for logging and debugging.
Example:
HTTP/1.1 401 Unauthorized
Content-Type: application/problem+json; charset=utf-8
Date: Wed, 07 Aug 2019 10:10:06 GMT
{
"type": "https://example.com/api/view-account-details",
"title": "Not authorized to view account details.",
"status": 401,
"detail": "Only users with the role manager are allowed to do this.",
"instance": "/account/3abed20f-4d52-4532-9853-b364003e9811/details"
}
Benefits:
- Standardization: Provides a common format for error reporting across different APIs.
- Machine-Readability: Allows clients to programmatically parse and interpret error details.
- Extensibility: Allows for custom fields to be added to provide more specific error information when needed.
- Improved Client Experience: Helps clients understand errors more effectively and handle them gracefully.




