I tried to POST like this : curl -X POST -H "Content-Type: application/json" -d "{ \"fisrtName\":\"sunny\" , \"lastName\":\"leone\" }" http://localhost:8080/user
But I get this error : {"timestamp":"2019-12-06T11:07:17.196+0000","status":405,"error":"Method Not Allowed","message":"Request method 'POST' not supported","path":"/user"}
But, I have my rest-controller like this :
@PostMapping("/user/{firstName}/{lastName}")
User addUser(@PathVariable String firstName,@PathVariable String lastName)
{
return userRepository.save(new User(firstName,lastName));
}
How this can be resolved ?
/useras you're using in your curl request? Does the method expects a JSON request body as you're sending in your curl request? - JB Nizet