{"record":{"id":"929612daca9ba183","repo":"eclipse-vertx/vert.x","slug":"415-unsupported-media-type","errorCode":null,"errorMessage":"415 Unsupported Media Type","messagePattern":"415 Unsupported Media Type","errorType":"http","errorClass":null,"httpStatus":415,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/http/HttpResponseExpectation.java","lineNumber":225,"sourceCode":"  /**\n   * 412 Precondition Failed\n   */\n  HttpResponseExpectation SC_PRECONDITION_FAILED = status(412);\n\n  /**\n   * 413 Request Entity Too Large\n   */\n  HttpResponseExpectation SC_REQUEST_ENTITY_TOO_LARGE = status(413);\n\n  /**\n   * 414 Request-URI Too Long\n   */\n  HttpResponseExpectation SC_REQUEST_URI_TOO_LONG = status(414);\n\n  /**\n   * 415 Unsupported Media Type\n   */\n  HttpResponseExpectation SC_UNSUPPORTED_MEDIA_TYPE = status(415);\n\n  /**\n   * 416 Requested Range Not Satisfiable\n   */\n  HttpResponseExpectation SC_REQUESTED_RANGE_NOT_SATISFIABLE = status(416);\n\n  /**\n   * 417 Expectation Failed\n   */\n  HttpResponseExpectation SC_EXPECTATION_FAILED = status(417);\n\n  /**\n   * 421 Misdirected Request\n   */\n  HttpResponseExpectation SC_MISDIRECTED_REQUEST = status(421);\n\n  /**\n   * 422 Unprocessable Entity (WebDAV, RFC4918)","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/HttpResponseExpectation.java#L207-L243","documentation":"SC_UNSUPPORTED_MEDIA_TYPE is the HttpResponseExpectation constant for HTTP 415 Unsupported Media Type. Vert.x provides it for response validation; a 415 failing this expectation surfaces '415 Unsupported Media Type'. The server refuses the request because the Content-Type (or the media type of the submitted resource) is not one it can process for that endpoint.","triggerScenarios":"Sending a request body via Vert.x WebClient with a Content-Type the endpoint rejects — e.g. sending JSON as text/plain, forgetting putHeader(\"Content-Type\", \"application/json\"), sending XML to a JSON-only API, or uploading with a wrong/missing MIME type in multipart.","commonSituations":"Using sendBuffer (which sets no Content-Type) instead of sendJson, typos in the media type string, API version change adding/removing supported formats, file uploads with mismatched extension/MIME.","solutions":["Set the correct Content-Type header explicitly: putHeader(\"Content-Type\", \"application/json\")","Prefer typed helpers: webClient.post(...).sendJson(obj) or sendBuffer with .putHeader — avoid bare sendBuffer for structured bodies","Check the endpoint documentation (or an OPTIONS request) for accepted media types","For multipart uploads, set the part's MIME type (e.g. application/octet-stream for binary)","Verify you did not accidentally send a serialized string of JSON with Content-Type text/plain"],"exampleFix":"// before\nwebClient.post(url).sendBuffer(jsonBuffer); // 415\n// after\nwebClient.post(url)\n  .putHeader(\"Content-Type\", \"application/json\")\n  .sendBuffer(jsonBuffer);\n// or simply: .sendJson(jsonObject)","handlingStrategy":"validation","validationCode":"// Always declare the body media type\nif (bodyMediaType == null || bodyMediaType.isBlank()) {\n  bodyMediaType = \"application/json\"; // or detect per payload\n}\nrequest.putHeader(\"Content-Type\", bodyMediaType);","typeGuard":"boolean isUnsupportedMediaType(Throwable t) {\n  return t instanceof VertxHttpResponseException\n    && ((VertxHttpResponseException) t).getResponse().statusCode() == 415;\n}","tryCatchPattern":"if (isUnsupportedMediaType(t)) { resendWithExplicitContentType(); } else { throw t; }","preventionTips":["Set Content-Type explicitly on every bodied request","Use sendJson/sendForm helpers instead of raw sendBuffer","Verify accepted media types per endpoint (docs or OPTIONS)","For uploads, set the correct part MIME type"],"tags":["http","content-type","media-type","serialization"],"backgroundTag":"invalid-argument-value","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}