Sunday, May 16, 2021

POST call forbidden (403) in Spring Boot application

If you are getting status code 403 (forbidden) error for a POST call in Spring Boot application and if you are fine with disabling CSRF (cross site request forgery), you can disable CSRF to continue your POST call.
Here is the code snippet to do this:


@EnableWebSecurity

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {


    @Override

    protected void configure(HttpSecurity http) throws Exception {

        http.csrf().disable();

    }

}



References:

  1. https://github.com/pyav/restful-web-services/blob/main/src/main/java/com/pyav/rest/webservices/restfulwebservices/WebSecurityConfig.java

Thursday, April 29, 2021

Issue resolution in maven project for Spring Boot application in Eclipse

Writing this post to record the steps to resolve the following issue in maven project while running it in Eclipse for a Spring boot application:

Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.3.RELEASE from/to central (http://repo.maven.apache.org/maven2)

Steps to resolve which worked for me:

  1. Update project:  Right click on the project -> Maven -> Update Maven Project (opens a pop-up window)
  2. Check the project in the "Available Maven Codebases" list.
  3. Check "Force Update of Snapshots/Releases".
  4. Click "OK".
  5. Build the project: Right click on the project -> Build Project.
  6. Run the application: Right click on the application code -> Run as -> Java application
Thanks for reading.