What is ASP.NET Core 2.1 API “Problem Details” (RFC 7807)

When ASP.NET Core 2.1 came out, there’s was a relatively brief announcement about new support for “Problem Details” (RFC 7807)

In this release we added support for RFC 7808 – Problem Details for HTTP APIs as a standardized format for returning machine readable error responses from HTTP APIs.

If you just want a better explanation of problem details, fear not. I read the documentation for you.  

Problem Details is nothing more than a standard JSON format and content type. Here’s a sample from the documentation:

The first three lines indicate the headers returned from the server. 403 is just a sample code. Your API can return any code it needs to return for a given error condition.  The Content-Type is important, though. 

The only problem details-specific elements for in this example are “type”, “title”, “detail”, and “instance”. 

“balance” and “accounts” are custom properties. That means you can include any additional data you want in your problem details. 

Honestly, it’s worth digging into the documentation if you want to know more, but here’s what I think is the most important bit: