sgt-hartman
sgt-hartman

Reputation: 653

Error response body format from a request with specific "Accept" header

My HTTP/Rest API has a resource endpoint that can handle "application/json" and "text/csv" response body formats which are specified via the "Accept" header on the request.

In case of error, like an HTTP 400, 500 response etc., i wonder what response body format should be used for returning error information. If used with application/json, it pretty obvious the error information must be in JSON format. But what format to use in case of text/csv, or any other more "exotic" mime types ?

Upvotes: 1

Views: 1535

Answers (1)

Evert
Evert

Reputation: 99851

A HTTP server is free to disregard the Accept header if none of the formats are available.

Given that there's not really a 'standard' CSV error response, I would default to application/problem+json, text/html or maybe even text/plain.

Upvotes: 1

Related Questions