Spring Boot - Request method 'POST' not supported

java, spring, spring-boot

Solution

I solved this issue by disabling the CSRF.

@Configuration
class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
    }
 }

Problem

I got exception `PageNotFound: Request method 'POST' not supported` in my Spring Boot app. This is my controller: ``` @RestController public class LoginController { UserWrapper userWrapper = new UserWrapper(); @RequestMapping(value = "/api/login", method = RequestMethod.POST, headers = "Content-type: application/*") public @ResponseBody ResponseEntity getCredentials(@RequestBody UserDTO userDTO) { User user = userWrapper.wrapUser(userDTO); if (userDTO.getPassword().equals(user.getPassword())) { return new ResponseEntity(HttpStatus.OK); } else { return new ResponseEntity(HttpStatus.BAD_REQUEST); } } } ``` I am sending post request at `localhost:8080/api/login` but it doesn't work. Have you got any idea? EDIT: UserDTO: ``` public class UserDTO implements Serializable { private String email; private String password; //getters and setters ``` And json i send: ``` { "email":"email@email.com", "password":"password" } ```

Original source