Method @PostMapping("/users") create(@RequestBody UserDto dto). Client gửi body JSON hợp lệ nhưng header là Content-Type: text/plain. Client nhận status gì?
Xem đáp án và giải thích
Với @RequestBody, Spring duyệt các HttpMessageConverter để tìm cái vừa đọc được kiểu đích vừa hỗ trợ Content-Type của request. Jackson converter chỉ nhận application/json và application/*+json, nên text/plain dẫn tới 415. Lỗi này hay gặp khi test bằng Postman/curl mà quên -H "Content-Type: application/json".