Monday 16 July 2018

OnFailure called and IOException thrown but data posted

This is my networkrequest sample

networkAPI.postData(myData).enqueue(new Callback<MyResponse>() {
            @Override
            public void onResponse(Call<MyResponse> call, Response<MyResponse> response) {
                 if (response.code() == 201) {
                     // success
                 }
            }
            @Override
            public void onFailure(Call<MyResponse> call, Throwable t) {

            }
        });

Its the request I should call only once as I've one time usable voucher code. If I turn off my network connection immediately or if it disconnects instantly after calling this method, then it moves to onFailure method with IOException in throwable which generally refers connection error, But the point is data posted to server and voucher code has been used and problem is onFailure method was called here.

I am sure that its not a parsing failure hence I tried using Void too. Why onResponse is not called even after posting the data. How to overcome such situation ?



from OnFailure called and IOException thrown but data posted

No comments:

Post a Comment