Stack Exchange
JAX-RS 405 Method not allowed
My GET functions for JAX-RS work perfectly. I am now working on my POST methods, but this keeps giving me 405 errors. My resource points towards my DAO.
Is there something faulty in my code?
REsource
@POST
@Path("/insert")
public void insertIngredient(@QueryParam("Q1") int hoeveelheid, @QueryParam("Q2") String datum,@QueryParam("Q3") String ingredientnaam , @QueryParam("Q4") String gebruikersnaam) {
    IngredientService service = ServiceProvider.getIngredientService();
    service.insertIngredient(hoeveelheid, datum, ingredientnaam, gebruikersnaam);
}

DAO
public void insertIngredient(int hoeveelheid, String datum, String ingredientnaam, String gebruikersnaam) {
    try (Connection con = super.getConnection()) {
        Statement stmt = con.createStatement();
        ResultSet nextId = stmt.executeQuery("SELECT MAX(dagboek_id) FROM dagboek");
        int maxId = nextId.getInt("dagboek_id") + 1;

        stmt.executeQuery("insert into dagboek(dagboek_id, hoeveelheid, datum, fk_ingredientnaam, fk_gebruikersnaam) values('"+maxId+"','" + hoeveelheid + "','" + datum + "','" + ingredientnaam + "','" + gebruikersnaam + "')");

    } catch (SQLException sqle) {
        sqle.printStackTrace();
    }
}


an HTTP 405 method not allowed means that you got the correct endpoint, but did not get a correct http method.  It has nothing to do with your implementation of the endpoint.  Common poential issues to check are:

Are you sure you're making the request as a POST?
Did you configure your server to allow POSTs to that particular endpoint?
Do you have a method overwriting filter somewhere?

