Spring REST @RequestBody is always empty Spring REST @RequestBody is always empty json json

Spring REST @RequestBody is always empty


I don't see a @RequestBody in your Controller for the UserLocation object? Also make sure your properties have getters and setters.

public UserLocation updateUserLocation(@PathVariable("id") int id, UserLocation user) {        

When doing a HTTP PUT, you WILL have to put extra logic to persist your object to the database. You will need to call your DAO or Repository to persist your object. Usually you map your incoming UserLocation object to a real JPA/Hibernate entity that you persist. This will not happen automatically.


Problem is you missed to annotate the UserLocation parameter with @RequestBody

..updateUserLocation(@PathVariable("id") int id, @RequestBody UserLocation user)

Also make sure to generate getters and setters for UserLocation memeber variables.