restquarkusmime-typescontent-typehttp-status-code-415

Accept text/plain while @Consumes has application/json


We migrated a DropWizard based REST service to Quarkus based one (version: 2.16.7.Final) using quarkus-resteasy-reactive extension. The APIs where the @Consumes annotation has application/json started failing in Quarkus with status code

415 (The content-type header value did not match the value in @Consumes)

when the request header has Content-Type set to text/plain (Note: The request body payload parameter is defined as a String in the method signature).

While having @Consumes with application/json in DropWizard still serves requests that send text/plain in the Content-Type header. So this became an issue with respect to supporting existing clients with this migration (from DropWizard to Quarkus).

Is there any configuration option/workaround to allow text/plain in Quarkus when the @Consumes just has application/json (to relax and not return 415 in this scenario)?

If not, should we be adding text/plain also to the @Consumes tag in the code, is that the only option?


Solution

  • Yes, you should also be adding text/plain to the @Consumes annotation.

    I am not sure why your case works in Dropwizard, but it seems like a pretty clear JAX-RS spec violation