Search code examples
javaspring-bootmavenpostman

Path mapping not happening


I'm using Java 17, Spring Boot 3 and Maven 3.9 for an API application. Right now, I'm trying to create a POST path and add new objects in the database (using MySQL). The database is created, and everything so far have been working properly.

It should be mapping a path to "localhost:3306/api/cadastrar-pj" where I should be able to POST new objects. The Postman test returns the error: "Error: Parse Error: Expected HTTP/" to the body:

{
    "nome": "Armando A. M. Vidal",
    "email": "[email protected]",
    "senha": "123456",
    "cpf": "44433322211",
    "razaoSocial": "Armando Ltda",
    "cnpj": "12345678912345"
}

Here is the link to the GitHub repository: https://github.com/Armando-Vidal/ponto-inteligente-api


Solution

  • The problem is that you are trying to access the port 3306, that is where your database is being hosted, while Spring Boot by default hosts the server at port 8080.

    If you access localhost:8080/api/cadastrar-pj it will work fine.