{"record":{"id":"230e6d4da5f11ac0","repo":"kestra-io/kestra","slug":"unsupported-content-type","errorCode":null,"errorMessage":"Unsupported content type ","messagePattern":"Unsupported content type ","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/HttpFunction.java","lineNumber":53,"sourceCode":"import jakarta.inject.Provider;\nimport jakarta.inject.Singleton;\n\n@Singleton\npublic class HttpFunction<T> implements KestraFunction {\n    public static final String NAME = \"http\";\n\n    private final MessageBodyWriter<T> FALLBACK_CONTENT_WRITER = (type, mediaType, object, outgoingHeaders, outputStream) ->\n    {\n        if (mediaType == MediaType.APPLICATION_YAML_TYPE || mediaType.equals(MediaType.of(\"application/yaml\"))) {\n            try {\n                outputStream.write(JacksonMapper.ofYaml().writeValueAsString(object).getBytes(StandardCharsets.UTF_8));\n                return;\n            } catch (IOException e) {\n                throw new PebbleException(e, \"Couldn't write the request body as YAML\");\n            }\n        }\n\n        throw new PebbleException(new IllegalArgumentException(\"Unsupported content type: \" + mediaType), \"Unsupported content type \");\n    };\n\n    @Inject\n    private DefaultMessageBodyHandlerRegistry defaultMessageBodyHandlerRegistry;\n\n    @Inject\n    private Provider<RunContextFactory> runContextFactoryProvider;\n\n    @Override\n    public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {\n        throwIfMissingArgs(args, self, lineNumber);\n\n        EvaluationContextImpl evaluationContext = (EvaluationContextImpl) context;\n        Map<String, Object> pebbleVariables = evaluationContext.getScopeChain().getGlobalScopes().stream()\n            .flatMap(scope -> scope.getKeys().stream())\n            .distinct()\n            .collect(HashMap::new, (m, k) -> m.put(k, context.getVariable(k)), HashMap::putAll);\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/HttpFunction.java#L35-L71","documentation":"Thrown by the 'http' function's fallback MessageBodyWriter when the requested contentType has no registered Micronaut writer and is not YAML. The fallback writer only knows how to emit YAML, so any other unregistered content type (or a body type with no matching writer) lands here.","triggerScenarios":"Calling http(..., body=<obj>, contentType='text/csv') (or 'application/xml', 'application/octet-stream', etc.) where Micronaut's DefaultMessageBodyHandlerRegistry has no writer for that type+body-class combination.","commonSituations":"Using a niche or custom MIME type, a typo in the contentType string, or expecting the function to auto-convert to a format Micronaut does not ship a writer for.","solutions":["Use a contentType with a registered writer — 'application/json' (default) or 'application/yaml'.","Correct typos in the contentType string (e.g. 'aplication/json').","If you truly need a custom content type, pre-format the body as a string and pass contentType 'text/plain'.","Register a custom Micronaut MessageBodyWriter for the MIME type if it must be a first-class type."],"exampleFix":"// before\n{{ http(uri, method='POST', body=payload, contentType='text/csv') }}\n// after\n{{ http(uri, method='POST', body=payload, contentType='application/json') }}","handlingStrategy":"validation","validationCode":"{% set ct = contentType ?? 'application/json' %}{% if ct not in ['application/json', 'application/yaml'] %}{% set ct = 'application/json' %}{% endif %}{{ http(uri, method='POST', body=payload, contentType=ct) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict contentType to 'application/json' or 'application/yaml'.","Verify the MIME type string is spelled correctly and is a real type/subtype pair.","Omit contentType unless you specifically need a non-JSON type."],"tags":["pebble","http","content-type","serialization","micronaut"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}