Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to resolve error 404 in postman with SpringBoot REST?

I am new to spring boot and i have been trying to get a simple api request via postman. But, I am stuck with an error 404. Can someone point the errors in my code?.

I have a spring boot simple app build with maven and run in embedded tomcat through STS. I tried to send this request

http://localhost:8080/api/vi/menu/getAll

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here is my controller code:

@RestController
@RequestMapping("/api/v1/menu")
public class MenuController {
  @Autowired
  private MenuRepository menuRepository;

  @GetMapping
  @RequestMapping("/getAll")
  public List<Menu> list() {
    return menuRepository.findAll();
  }
 }

MenuRepository:

public interface MenuRepository extends JpaRepository<Menu, Integer> {}

The error status in postman:

{
"timestamp": "2022-08-05T04:46:28.489+00:00",
"status": 404,
"error": "Not Found",
"path": "/api/vi/menu/getAll"
}

The port is in default 8080.

I tried adding url to the getmapping after referring some online documentations, but still the error 404 is not resolved. Can someone point the error and explain me ?

Thanks.

>Solution :

You are calling wrong URL

   /api/vi/menu/getAll

correct url is

     /api/v1/menu/getAll

Change vi to v1

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading