Reputation: 12903
I'm building an API, and for the most part there will be JSON and HTML content there. But a few very specific endpoints only render true
or false
, and also accept true
or false
in POST. That is the entire body of the request or response.
What would be the correct content-type header for this resource?
I'm using text/plain
. application/text
also sounds ok, though it I haven't found it used anywhere else (is it?)
Upvotes: 5
Views: 9104
Reputation: 2167
The single words true
or false
are valid JSON, so you may use application/json
with these values.
However, it is recommended that your JSON messages be either an object or an array as some software may not work properly if this is not the case. To follow that recommendation you might instead return a value such as
{"result":true}
Upvotes: 16