Calin
Calin

Reputation: 6847

How handle html responses in a Restful Api

I am working on a large api, it tries to be restful (and for most part it succeeds), one of our client requires a term of service in html format.

Is it ok to have a endpoint that returns html in a restful json api? Are there better alternatives?

Upvotes: 0

Views: 799

Answers (1)

Razvan Manolescu
Razvan Manolescu

Reputation: 434

I believe it's best to have the client dictate the content type via Accept header in the HTTP request. You can default to application/json and have the client call the API they require with a text/html Accept header.

It is okay for RESTful services to return any media type, as long as the API itself is agnostic of it.

Upvotes: 1

Related Questions