Is there a way to query what media types a server endpoint supports?

18 Views Asked by At

HTTP 415 ("Unsupported Media Type") tells us when a server doesn't support a media type, but how can a client query what media types a server supports (for the request body)?

In other words, I'm looking for the server equivalent of an Accept header. While it’s possible to provide this information beyond the scope of the HTTP specification, I specifically seek an answer from within the HTTP specification itself.

If no mechanism exists, does that mean that adding support for a new server requires human intervention every time?

1

There are 1 best solutions below

0
Gili On

Answering my own question... It turns out that as of RFC9110 the Accept header now works in both directions (!!)

15.5.16. 415 Unsupported Media Type

[...] On the other hand, if the cause was an unsupported media type, the Accept response header field (Section 12.5.1) can be used to indicate which media types would have been accepted in the request.

12.5. Content Negotiation Fields 12.5.1. Accept

[...] When sent by a server in a response, Accept provides information about which content types are preferred in the content of a subsequent request to the same resource.