Zuly
Zuly

Reputation: 37

call.enqueue dose not work and response.body is null in retrofit

When calling json link only give Header value Authorization=token, response is null. onResponse method is not working, but there is no error. No reach On failure stage. How I get any JSON data?

Any help would be appreciated.


Upvotes: 2

Views: 440

Answers (1)

Milan Pansuriya
Milan Pansuriya

Reputation: 2559

you will get response code from the response try this way to handle request response and handle your error messages according to the response code

 public void onResponse(Call<DDL> call, Response<DDL> response) {

                            if (response.code()==200) {
Log.e("Here Arrived ID", response.body().getId());
                                try {

                                    DDLList = (List<DDL>) response.body();
                                    a = response.body().getProcessCode();
                                    Log.e("Here Arrived 2", "arlala");

                                } catch (Exception e) {
                                    Toast.makeText(convertView.getContext(), "No Data", Toast.LENGTH_SHORT).show();
                                    Log.e("Here Arrived 3", "nodata");
                                }
                            } else {
                                Log.e("Here Arrived 4", "json is null");
                                //   Toast.makeText(getApplicationContext(), "No Data", Toast.LENGTH_SHORT).show();
                            }

Upvotes: 1

Related Questions