Dalibor Karlović
Dalibor Karlović

Reputation: 568

Specify allowed content types when anwering with HTTP 415

I'm looking into adding (more) precise responses to REST API client (4xx) errors. The direction seems quite clear, as seen here:

406 [sic] when you can't send what they want, 415 when they send what you don't want.

The difference seems to be that you can include allowed methods via the Allow header:

< PUT /api/articles/
> HTTP 405 Method Not Allowed
> Allow: POST

But there isn't any equivalent response header for:

< POST /api/images/
< Content-Type: text/html
> HTTP 415 Unsuported media

The way I see it, I have the following options:

  1. Sending Accept which is exactly for this, but a request-only header
  2. Sending Warning which doesn't seem right at all.

Did I miss something obvious?

Upvotes: 0

Views: 96

Answers (1)

Julian Reschke
Julian Reschke

Reputation: 42017

This proposal:

https://datatracker.ietf.org/doc/html/draft-wilde-accept-post-02

might be of interest.

Upvotes: 1

Related Questions