I am trying to make a call via retrofit of a list of objects (Cadastros) and in the HttpLogginInterceptor the response is appearing normally. What could be happening?
My call:
CadastroApi cadastroApi = retrofit.create(CadastroApi.class);
Call<List<Cadastro>> callCadastros =cadastroApi.getCadastro(token);
callCadastros.enqueue(new Callback<List<Cadastro>>() {
@Override
public void onResponse(Response<List<Cadastro>> response, Retrofit retrofit) {
List<Cadastro> cadastroList = response.body();
if (cadastroList != null){
Log.i("ACTTOKEN","Resultado da resposta cadastro: "+cadastroList.get(1).getCpf_cnpj());
// Insere o cadastro no banco de dados
try {
DBHelper dbHelper = new DBHelper(TokenActivity.this,token);
SQLiteDatabase conn = dbHelper.getWritableDatabase();
RepositorioCadastro repositorioCadastro = new RepositorioCadastro(conn);
for (Cadastro cadastro : cadastroList){
repositorioCadastro.inserirCadastro(cadastro);
}
}catch (SQLiteException e){
Log.i("ACTTOKEN","Erro ao inserir cadastro: "+e);
}
}
}
@Override
public void onFailure(Throwable t) {
// Em caso de erro
Log.i("ACTTOKEN", "Erro retrofit ao baixar Cadastros: " + t.getCause());
}
});
My API:
public interface CadastroApi {
@POST("Cadastro_Down.php?token=")
Call<List<Cadastro>> getCadastro(@Query("token") String token);
}
WebService response
[{
"id": "-1",
"data": null,
"nome": "CLIENTE VENDA R\u00c1PIDA",
"cpf_cnpj": "1111111111",
"email": "[email protected]",
"fone": null,
"celular": null,
"fax": null,
"status": "1",
"obs": null,
"municipal": null,
"estadual": null,
"rg": null,
"foto": null,
"sexo": null,
"data_nas": null,
"nome_fantasia": null,
"forca_venda": null,
"id_vendedor": "2",
"limite": "0.00",
"casado": "",
"pai": "",
"mae": "",
"fiado": "0.00"
}, {
"id": "91",
"data": "2016-01-09",
"nome": "SAMUEL RAUL PINTO",
"cpf_cnpj": "65573998455",
"email": "[email protected]",
"fone": "(69) 2925-9737",
"celular": "(69) 8508-5128",
"fax": "(69) 2925-9737",
"status": "1",
"obs": "f7WDsqCrfc",
"municipal": "",
"estadual": "",
"rg": "37.922.970-5",
"foto": "",
"sexo": "MASCULINO",
"data_nas": "1994-06-10",
"nome_fantasia": "",
"forca_venda": null,
"id_vendedor": "1",
"limite": "10000.00",
"casado": "N\u00c3O",
"pai": "AGENOR",
"mae": "RORAIMA",
"fiado": "5000.00"
}]