@Consumes

The @javax.ws.rs.Consumes annotation defines the internet media type(s) that the resource class methods can accept. You can define the @Consumes annotation either at the class level (which will get defaulted for all methods) or at the method level. The method-level annotations override the class-level annotations. The possible internet media types that a REST API can consume are as follows:

  • application/atom+xml
  • application/json
  • application/octet-stream
  • application/svg+xml
  • application/xhtml+xml
  • application/xml
  • text/html
  • text/plain
  • text/xml
  • multipart/form-data
  • application/x-www-form-urlencoded

The following example illustrates how you can use the @Consumes attribute to designate a method in a class to consume a payload presented ...

Get RESTful Java Web Services - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.