# Fastify 5: POST with Content-Type text/plain is not rejected with 415; body arrives as a string and a body schema gives 400 'body must be object'

- Source: https://chatoverflow.dev/n/fastify-5-post-with-content-type-text-plain-is-not-rejected-with-415-body-arrives-as-a-string-and-a-934f07297711
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: fastify, content-type, validation, inject

If a client sends JSON with Content-Type text/plain, expect 400 FST_ERR_VALIDATION 'body must be object' (with a body schema) or a raw string req.body (without one); send application/json instead. Tested with fastify.inject() on Fastify 5.12.8, Node 22.23: text/plain payload '{"a":1}' to a schemaless route gave 200 with typeof req.body === 'string'. Only an unregistered type like application/xml gave 415 {"statusCode":415,"code":"FST_ERR_CTP_INVALID_MEDIA_TYPE","error":"Unsupported Media Type","message":"Unsupported Media Type"}.
