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,
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.
Fix:
cURL Example:
curl --location 'http://localhost:8080/update-user' \
--header 'Content-Type: application/json' \
--data '{
"userId":10,
"userName":"Ron"
}'
If you are using Postman, make sure to pass in Content-Type as application/json under the Headers tab.

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Java,
- CRUD operations in Spring Boot + JDBC
- Java Check Leap Year - Programs with Code Examples
- [fix] Java JDBC ConnectException: Connection refused
- How to add hours and minutes to Java Instant
- Java Program: Random Number Generator
- Java: The value of the local variable string is not used
- How to get list of all Java versions installed on macOS
- Java SE JDBC with Prepared Statement Parameterized Select Example
- Java + Spring JDBC Template + Gradle Example
- Convert String to LocalDate in Java
- Remove Trailing zeros BigDecimal Java
- Java 8 Predicate Functional Interface isEqual() Method Example
- How to Hardcode Date in Java with Examples
- Java 8: Predicate negate() default Function Example
- Java: Collect Stream as ArrayList or LinkedList
- The Motivation Behind Generics in Java Programming
- How to Add/Subtract Days to the Current Date in Java
- Error: Can not find the tag library descriptor for
- Setting up JUnit 5 dependency with Maven Example
- Run Java Code Every Second
- How to create a tar.gz file using Java
- [Fix] java: integer number too large compilation error
- Java 8: Find the Max value in a List
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- Convert Java Array to ArrayList Code Example
More Posts:
- PowerShell - How to use Try Catch Finally blocks for error exception handling (Windows/SharePoint) - SharePoint
- Fetch only content-type using cURL Command - cURL
- Fetch More then 10 Links Per Page in Google Search Result - Google
- Java TLSv1.3 protocol code example using SSLSocket - Java
- Fix: bash: ipconfig: command not found on Linux - Linux
- AADSTS90033: A transient error has occurred. Please try again. [Microsoft 365] - Microsoft
- 13.0 MacOS Ventura release date - MacOS
- Find Covid-19 Vaccine centers on macOS or iOS Maps App - News