Introduction to content types and content negotiation

In this section, we're going to take a look at using the @Produces and @Consumes annotations to specify the content types. We'll also learn about API versioning using custom content types, smart content negotiation using a quality from server factor, and how you can serve and upload binary content.

Let's switch to code and open our IDE. Let's take a look at the small REST service that we have prepared. As you already know, you can specify the @Produces or @Consumes annotations to specify what your REST service will consume as a content type and what content type your REST service will produce. What we do here is we specify application/json. This is what we usually do. We implement this ...

Get Building RESTful Web Services with Java EE 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.