{"record":{"id":"cd58570fdee76ee9","repo":"quarkusio/quarkus","slug":"the-content-type-header-value-did-not-match-the-va-cd5857","errorCode":null,"errorMessage":"The content-type header value did not match the value in @Consumes","messagePattern":"The content-type header value did not match the value in @Consumes","errorType":"http","errorClass":"NotSupportedException","httpStatus":415,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/RequestDeserializeHandler.java","lineNumber":65,"sourceCode":"\n    @Override\n    public void handle(ResteasyReactiveRequestContext requestContext) throws Exception {\n        requestContext.requireCDIRequestScope();\n        MediaType effectiveRequestType = null;\n        Object requestType = requestContext.getHeader(HttpHeaders.CONTENT_TYPE, true);\n        if (requestType != null) {\n            try {\n                effectiveRequestType = MediaTypeHelper.valueOf((String) requestType);\n            } catch (Exception e) {\n                log.debugv(\"Incorrect media type\", e);\n                throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).build());\n            }\n\n            // We need to verify media type for sub-resources, this mimics what is done in {@code ClassRoutingHandler}\n            if (MediaTypeHelper.getFirstMatch(\n                    acceptableMediaTypes,\n                    Collections.singletonList(effectiveRequestType)) == null) {\n                throw new NotSupportedException(\"The content-type header value did not match the value in @Consumes\");\n            }\n        } else if (!acceptableMediaTypes.isEmpty()) {\n            effectiveRequestType = acceptableMediaTypes.get(0);\n        } else {\n            effectiveRequestType = MediaType.APPLICATION_OCTET_STREAM_TYPE;\n        }\n        List<MessageBodyReader<?>> readers = serialisers.findReaders(null, type, effectiveRequestType, RuntimeType.SERVER);\n        if (readers.isEmpty()) {\n            log.debugv(\"No matching MessageBodyReader found for type {0} and media type {1}\", type, effectiveRequestType);\n            throw new NotSupportedException();\n        }\n        for (MessageBodyReader<?> reader : readers) {\n            if (isReadable(reader, requestContext, effectiveRequestType)) {\n                Object result;\n                ReaderInterceptor[] interceptors = requestContext.getReaderInterceptors();\n                try {\n                    try {\n                        if (interceptors == null) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/RequestDeserializeHandler.java#L47-L83","documentation":"Thrown as a JAX-RS NotSupportedException when the request's Content-Type header does not match any media type declared via @Consumes on the targeted (sub-)resource method. For sub-resources this check mimics ClassRoutingHandler since routing happened on the locator. The server rejects the request before deserialization.","triggerScenarios":"Client sends a Content-Type (e.g. application/xml) that no @Consumes value on the resource method matches; calling a sub-resource whose @Consumes differs from what routing matched; sending no Content-Type when the method requires one.","commonSituations":"Clients posting form data with wrong content type (text/plain instead of application/x-www-form-urlencoded); API version changes adding @Consumes restrictions; sub-resource locators narrowing acceptable types.","solutions":["Send a Content-Type header matching one of the method's @Consumes values","Widen @Consumes on the resource method (e.g. add the media type or MediaType.WILDCARD)","Check the sub-resource class's @Consumes, not just the locator method","Fix client library defaults that set an unexpected Content-Type"],"exampleFix":"// before\n@POST\n@Consumes(MediaType.APPLICATION_JSON)\npublic String create(String body) { ... }\n// client sends Content-Type: text/plain\n// after: client sends\n// Content-Type: application/json\n// or widen:\n@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})","handlingStrategy":"validation","validationCode":"MediaType ct = MediaType.valueOf(request.getHeader(\"Content-Type\"));\nboolean ok = consumes.stream().anyMatch(c -> c.isCompatible(ct));","typeGuard":null,"tryCatchPattern":"try { return resource.post(entity); } catch (NotSupportedException e) { log.warn(\"Content-Type not in @Consumes: {}\", e.getMessage()); return Response.status(415).build(); }","preventionTips":["Set explicit Content-Type on every client request","Keep @Consumes permissive unless validation requires narrowing","Check sub-resource classes' @Consumes too, not just locators"],"tags":["resteasy-reactive","content-type","consumes","http-415"],"backgroundTag":"unsupported-media-type","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}