request method 'post' not supported 405 code example

Example 1: Request method 'GET' not supported 405

@RestController
@RequestMapping(value="/api")
public class RequestMethodController {
 
    @Autowired
    private EmployeeService service;
 
    @RequestMapping(value = "/employees", produces = "application/json")
    public List<Employee> findEmployees()
      throws InvalidRequestException {
        return service.getEmployeeList();
    }
}

Example 2: "status": 405, "error": "Method Not Allowed",

the possibility is that you have use wong request type:GET instead of POST or something else

Tags:

Misc Example