java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN retrofit_ARRAY at line 1 column 13571

  android, retrofit2

I corrected my code according to the answer here
Retrofit Expected BEGIN_OBJECT but was BEGIN_ARRAY

but still I am getting same error.

here is a sample of my json response

[
{
    "id": 5095,
    "parent_id": 0,
    "number": "5095",
    "order_key": "wc_order_q7QgiKvemzxBd",
    "created_via": "checkout",
    "version": "5.0.0",
    "status": "processing",
    "currency": "USD" 
 },

 {
    "id": 5094,
    "parent_id": 5090,
    "number": "5094",
    "order_key": "wc_order_PeUZBs1eRRgHC",
    "created_via": "dokan",
    "version": "5.0.0",
    "status": "processing",
    "currency": "USD"
 }
]

ApiInterface method:

 @Headers({"Content-Type: application/json"})
@GET("wp-json/wc-analytics/orders")
Call<List<OrdersModel>> getAllOrdersWuCo();

This is how I am calling it

 Call<List<OrdersModel>> allOrdersWuCo = apiInterfaceTwo.getAllOrdersWuCo();
    allOrdersWuCo.enqueue(new Callback<List<OrdersModel>>() {
        @Override
        public void onResponse(Call<List<OrdersModel>> call, Response<List<OrdersModel>> response) {
            List<OrdersModel> list = response.body();

        }

        @Override
        public void onFailure(Call<List<OrdersModel>> call, Throwable t) {
            String message = t.getMessage(); 
        }
    });

Source: Android Questions

LEAVE A COMMENT