0

I'm trying to receive a request in a list and I get the following error

    public void localizarPlaca(View view){
    final CompositeDisposable disposables = new CompositeDisposable();
    String token = getTokenEmpresa(getBaseContext());
    EditText placaParaPesquisar = findViewById(R.id.placaLocalizarPlaca);
    String placaParaLocalizar = placaParaPesquisar.getText().toString();
    String url = Preferencias.apiv3Link +
            "vistorias/busca-por-placa/" +
            token + "/" + placaParaLocalizar + "/tes";
    Observable<List<PojoRequestLocalizadorPlaca>> vistoriasObservable = getVistoriasPlaca(url);
    DisposableObserver<List<PojoRequestLocalizadorPlaca>> observer = new DisposableObserver<List<PojoRequestLocalizadorPlaca>>() {
        @Override
        public void onNext(List<PojoRequestLocalizadorPlaca> vistoriasObservable2) {
            ShowCards(vistoriasObservable2);
        }

        @Override
        public void onError(Throwable e) {
            String errorMessage = "Erro ao receber vistorias do localizar placa";
            Logger.error(errorMessage, new Exception(e), getApplicationContext());
        }

        @Override
        public void onComplete() {}
    };

    disposables.add(vistoriasObservable.subscribeWith(observer));
}

Function that I perform the request

    private Observable<List<PojoRequestLocalizadorPlaca>> getVistoriasPlaca(String url){
    RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
    RequestFuture<String> future = RequestFuture.newFuture();

    StringRequest request = new StringRequest(
            Request.Method.GET,
            url,
            future,
            future
    );
    queue.add(request);

return the request return Observable .fromFuture(future, 4, TimeUnit.SECONDS) .map(response -> Collections.singletonList(new Gson().fromJson(response, PojoRequestLocalizadorPlaca.class))) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()); }

  • Look like the same issue mentioned here - https://stackoverflow.com/questions/9598707/gson-throwing-expected-begin-object-but-was-begin-array?rq=1 – Fedric Antony Jun 03 '22 at 14:59

0 Answers0