Is it ever acceptable for REST API to return something other than JSON/XML? -
i trying build rest endpoint whereby authenticated user can download pdf. in researching proper way this, have seen json or xml proper response bodies give. however, this site explains response can other json long it's human-readable document.
so, ever okay rest api return application/pdf response type instead of application/json or application/xml?
yes, definitely, restful api can return whatever wants. there no constraint human-readable (although think linked article tries argue opposite). think of web, rest-based, returning images, movies, runnable code.
there some constraints. representation returned should 'self-contained', meaning has has every piece of information necessary client make sense of it. in case, mean set type 'application/pdf' on response.
Comments
Post a Comment