Error trying to delete with DELETE method using web service rest in Java [duplicate]

1

I created a REST Web Service in Java. All operations are working less than DELETE which returns the following error:

HTTPDELETEmethod:

@DELETE@Path("excluir/{idpromocao}")
public void excluir(@PathParam("idpromocao") int idpromocao){    
    Promocao P = new Promocao();
    P.setIdpromocao(idpromocao);

    PromocaoOp promo = new PromocaoOp();
    P = promo.buscar(P);

    promo.remove(P);
}

Exclusion Method:

public void remove(Promocao promocao) {
    id_conexao = N.Conectar();

    String sql = "delete from promocao where idpromocao=?";

    try {


        stmt = id_conexao.prepareStatement(sql);
        stmt.setInt(1, promocao.getIdpromocao());

        //executa
        stmt.execute();

        System.out.println("Excluido");

    } catch (SQLException e) {
        System.err.println("ERRO ao excluir promoção - " + e);

    } finally {
        N.Desconectar();
    }
}
    
asked by anonymous 25.10.2017 / 04:40

1 answer

0

See the first line of your picture:

Thereitsays:

GET SolicitaçãoFailed RequestFailed --> Status: (405)

Notice that the first word is GET . It should be written DELETE .

That is, the code that is trying to call your service is using the wrong HTTP method.

Also, take a look on this question to improve your JDBC.

    
25.10.2017 / 05:03