RESTfully request sub-parts of a representation be of a certain content-type

Posted by Grayside on Stack Overflow See other posts from Stack Overflow or by Grayside
Published on 2012-10-24T22:57:18Z Indexed on 2012/10/24 23:00 UTC
Read the original article Hit count: 232

Filed under:
|
|
|

I am requesting (via Accept: application/json) that an API I'm designing respond as JSON. However, I want the values within that JSON to be specified to conform to text/plain or text/html depending on the capabilities of the client.

What is the RESTful best practice for a "sub-type"? How would this work if I formally switched to HAL as the top-level container?

Accept: application/json+text/plain

{
  "value": "Hello World"
}

Accept: application/json+text/html

{
  "value": "<h2>Hello World</h2>"
}

© Stack Overflow or respective owner

Related posts about http

Related posts about rest