Fix: Spring Boot REST HTTP Status 415 - Unsupported Media Type Error

If you are trying to perform a POST/DELETE API call using Spring Boot REST (@RestController) and you get HTTP 415 error, well that's because you need to provide the header type as,

Content-Type: application/json

If you do not provide a Content-Type header, by default the Request will be considered as plain text and you would also see a warning in your application logs.

WARN 4189 --- [nio-8080-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type 'text/plain;charset=UTF-8' is not supported]


cURL Example:

curl --location 'http://localhost:8080/update-user' \
--header 'Content-Type: application/json' \
--data '{

If you are using Postman, make sure to pass in Content-Type as application/json under the Headers tab.

Adding Content-Type in Postman

Have Questions? Post them here!