How to create a custom media type (application/vnd) for a RESTful web service?

@JohnDoDo

One first question: Does the media type define the contract between my server and client?

Yes, media type is one part of the contract. Contract in REST API is not static unlike SOAP(i.e. WSDL). Contract is defined by combination of underlying protocol(i.e. HTTP), URIs and Media Types(it’s not prohibited to use several media types together). Media type defines data model, processing model, hypermedia controls(i.e. annotated links, input forms etc…) and support to include additional application specific information described by link relations, element names, ids, class names etc…

The media type will define my message formats so I need to add XML schema and JSON schema to go with the new media types (so that REST clients know what’s coming in messages and what to send back).

You only need to define generic schemas which cover structure of the document. You do not need to define separate schemas for particular messages. Your messages must feet in the structure defined by media type.

How can a new – fully functional – application/vnd media type be created? and what do you need to take care of so that clients can properly use it?

  1. Describe it(i.e. write format specification);
  2. Register with IANA: http://www.iana.org/cgi-bin/mediatypes.pl registering media type under vnd.* tree takes nearly one week to register.

Leave a Comment