79606423

Date: 2025-05-05 06:31:13
Score: 1.5
Natty:
Report link

You should not make POST request in your browser using a URL directly. Browser can only make GET requests when you enter a URL in the address bar. And since your endpoint is mapped to @PostMapping and you are sending a GET the server responds with a 405 method not allowed error.

You can either change the mapping to @GetMapping or keep the @PostMapping and call it with JavaScript fetch API or with Postman as mentioned in previous answers or curl:

curl -X POST http://localhost:8080/api/command/on
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @PostMapping
  • User mentioned (0): @GetMapping
  • User mentioned (0): @PostMapping
  • Low reputation (1):
Posted by: Christian S