@PathVariable
Learn how to use path variables for parameterizing the REST endpoints.
In this lesson we will create a new endpoint for our REST API to retrieve a single player based on the id
field. We will fetch the required player from the Player
table.
Path variables
Path variables are a way of parameterizing the path or endpoint to accept data. Path variables are written in curly braces. When the client sends a request, it passes a value in place of the path variable. For example, we could say /players/1
to give us the player with Id 1
, or /players/3
for the player with Id 3
.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.