Enable HTTP Request POST in Spring Boot

Sometimes especially during initial testing Spring's csrf - Cross Site Request Forgery - protection kicks in by default and prevents POST requests from taking place, a temporary workaround is to disable csrf. This is typically done in your Web Security Config class which extends WebSecurityConfigurerAdapter

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .csrf().disable();
    }
}

Note: This works as on Spring boot version 2.0.0.RC1 and its best if this IS NOT be used as permanent work around


A different solution worked for me. I just needed to add the proper annotation to the controller itself, like this:

@RestController
public class EntriesController {
    //your code here
}