{"record":{"id":"c02a4d04ccb65c24","repo":"quarkusio/quarkus","slug":"the-content-type-header-value-did-not-match-the-va-c02a4d","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/MediaTypeMapper.java","lineNumber":72,"sourceCode":"        for (Holder holder : resourcesByConsumes.values()) {\n            holder.setupServerMediaType();\n        }\n    }\n\n    @Override\n    public void handle(ResteasyReactiveRequestContext requestContext) throws Exception {\n        // find the best matching consumes type. Note that the arguments are reversed from their definition\n        // of desired/provided, but we do want the result to be a media type we consume, since that's how we key\n        // our methods, rather than the single media type we get from the client. This way we ensure we get the\n        // best match.\n        MediaType consumes = MediaTypeHelper.getBestMatch(contentTypeFromRequest(requestContext), consumesTypes);\n        Holder selectedHolder = resourcesByConsumes.get(consumes);\n        // if we haven't found anything, try selecting the wildcard type, if any\n        if (selectedHolder == null) {\n            selectedHolder = resourcesByConsumes.get(MediaType.WILDCARD_TYPE);\n        }\n        if (selectedHolder == null) {\n            throw new NotSupportedException(\"The content-type header value did not match the value in @Consumes\");\n        }\n        RuntimeResource selectedResource;\n        if (selectedHolder.mtWithoutParamsToResource.size() == 1) {\n            selectedResource = selectedHolder.mtWithoutParamsToResource.values().iterator().next();\n        } else {\n            MediaType produces;\n            try {\n                produces = selectMediaType(requestContext, selectedHolder);\n            } catch (IllegalArgumentException e) {\n                // Accept contained no parseable media type tokens\n                throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).build());\n            } catch (Exception e) {\n                // there is TCK testing this, but some of the legacy RESTEasy tests do expect the result to be 400\n                throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).build());\n            }\n            requestContext.setResponseContentType(produces);\n            MediaType key = produces;\n            if (!key.getParameters().isEmpty()) {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java#L54-L90","documentation":"In the MediaTypeMapper handler (used for resources with multiple methods distinguished by media types), this NotSupportedException (HTTP 415) is thrown when the request's Content-Type cannot be found in resourcesByConsumes, including after falling back to the wildcard entry. It means no resource method variant is registered that can consume the request's content type. Like error 3650 but raised at MediaTypeMapper.handle time rather than during initial validation.","triggerScenarios":"A request hits a resource handled by MediaTypeMapper; handle() looks up resourcesByConsumes.get(consumes) for the parsed request content type, gets null, also gets null for MediaType.WILDCERD_TYPE fallback, and throws at line 72 — e.g. sending Content-Type: text/plain where the mapper only has application/json and wildcard variants are absent.","commonSituations":"Clients posting a different body format than any registered @Consumes variant; adding a new @Consumes variant but forgetting to redeploy/register it; content-type negotiation misconfiguration between gateway-rewritten headers and server mappings.","solutions":["Send the request with a Content-Type matching one of the endpoint's registered @Consumes values.","Add a resource method (or extend the existing one's @Consumes) covering the missing media type.","Check that any header-rewriting proxy isn't converting the Content-Type to something unexpected."],"exampleFix":"// before\n@POST\n@Consumes(MediaType.APPLICATION_JSON)\npublic Response create(String body) { ... }\n// after\n@POST\n@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})\npublic Response create(String body) { ... }","handlingStrategy":"validation","validationCode":"// verify the endpoint accepts the content type before posting\njava.util.Set<String> consumed = java.util.Set.of(\"application/json\");\nif (!consumed.contains(contentType)) {\n    throw new IllegalStateException(\"Endpoint does not accept \" + contentType);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return client.post(entity);\n} catch (NotSupportedException e) {\n    log.error(\"No @Consumes variant for {} — check server mappings\", contentType, e);\n    throw e;\n}","preventionTips":["Register a wildcard @Consumes variant if the endpoint must accept arbitrary types.","Regenerate/redeploy resource mappings whenever Content-Type variants change.","Check proxy configurations that rewrite Content-Type headers."],"tags":["rest","http-415","content-type","content-negotiation"],"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"}