How supported Headers and Media Types are "discovered" with HATEOAS?

25 views Asked by At

Simply put, imagine a particular resource can be served using different Media Types (e.g. application/vnd.com.example.resource-v1+json and application/vnd.com.example.resource-v2+json).

My question is, how does a client know of these options for a RESTful Hypermedia-driven service (using HATEOAS)?

I see HAL provides a type and a profile field that seems to be related (here), but I don't see much adoption or examples on whether/how these fields should be used to communicate the supported Media Types for the resource.

1

There are 1 answers

0
Evert On

One option I've used for this in the past is the Link header, with a an alternate rel. For example:

Link: </foo>; rel="alternate" type="text/csv" title="CSV version"