I’m trying to make a POST request, but Postman is returning an error. Help me!

Asked

Viewed 52 times

0

Controller:

package Controlador;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import RecebaInformacoes.SistemaInf;
import Repositorio.SaveEntidade;

@RestController  //definir um controlador REST
public class Controller {
        @Autowired private SaveEntidade entidade;
        
        @PostMapping(value = "/teste", consumes = MediaType.APPLICATION_XML_VALUE ) 
        public String processar(@RequestBody SistemaInf information) {
            entidade.save(information);
            
            return "Nice Men";
        }
}

Reply Postman:

{"timestamp":"2020-10-19T14:05:39.423+00:00","status":404,"error":"Not Found","message":"No message available","path":"/teste"}
  • update the question with your main, the most likely is that your controller class is not being scanned

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.