How AI is applied across API Evangelist and APIs.io. Read my AI disclosure →
API Evangelist API Evangelist
Discovery
Learnings
Guidance
Toolbox
Alignment
API Evangelist LLC

Spring Boot: Required headers at controller level and error 400 Bad Request instead 404 Not Found

calendar_today July 3, 2026 person Marcelo domain spring-boot

I have a @RestController that has a required header. If I specify it in the @RequestMapping annotation family, etc.: @RestController @RequestMapping(“/mycontroller”, headers = [“X-Custom-Header”]) class MyController { @GetMapping fun hello() = “Hello World” } If the user doesn’t send it, a 404 Not Found error is generated with the message No static resource mycontroller. However, if I specify it as a parameter of the method: @RestController @RequestMapping(“/mycontroller”) class MyController { @GetMapping fun hello( @RequestHeader(“X-Custom-Header”) header: String, ) = “Hello World” } If the u

open_in_new Read original post