Spring boot – Request method ‘POST’ not supported. Tried everything

Following might help.

  1. While you deploy the application, spring boot displays all the available services on the console. Check the POST method to create is being displayed or not. Check that there shouldn’t be any contradiction with other services. GET/PUT/POST
  2. If there are services not deployed, try adding ‘/’ before other services – GET, PUT, POST.
  3. Adding exception handler(link) to check the client input request to check the POJO structure.
  4. Check the URL – If any global path for app/name added with configuration.(link)
  5. Try to remove headers – Content-Type in the request header and post the request again

Following are different things that can happen. Need not to be followed in order.

EDIT:

Run the following to check whether your controller is being enabled and considered by the spring application or not.

import java.util.Arrays;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(Application.class, args);

        System.out.println("Let's inspect the beans provided by Spring Boot:");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }
    }

    }

Leave a Comment