@PutMapping

Learn how to update a record in the database using a PUT request.

We'll cover the following

In this lesson, we will create an endpoint to edit a player record and update his information in the database.

The HTTP PUT request is used for updates. The REST client will send a PUT request to /players/{playerId} with JSON data containing the information to be updated. The player’s ID is a path variable.

The REST service will convert the JSON data to a Player object, and using the id of the player; it will overwrite the player’s record in the database with the one sent in the PUT request. On success, the REST service will respond with the updated player record (which is an echo of the request).

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.