I already have a method that takes a json and persists in the Mysql database. I can test it by the interface created by Netbeans, which has a field for inserting a json, but how do I, within a java application, make an http request by passing json as a parameter to be persisted? >
Method used for data persistence:
@PUT
@Consumes("application/json")
public void putJson(String json) throws Exception{
Cliente cliente;
Gson gson = new Gson();
java.lang.reflect.Type tipo = new TypeToken<Cliente>(){}.getType();
cliente = gson.fromJson(json, tipo);
Conexao con = new Conexao();
con.conexao();
PreparedStatement ps = con.con.prepareStatement("insert into cliente values(?,?)");
ps.setString(1, cliente.getCnpj());
ps.setString(2, cliente.getRazao_social());
ps.execute();
}
Thanks in advance!