probelalkhan / Retrofit-Android-Tutorial

48 stars 61 forks source link

JSON document was not fully consumed #1

Open Ehtasha opened 5 years ago

Ehtasha commented 5 years ago

Hello Simplified Coding! Thanks for your tutorials it really help us. I follow your tutorial of Retrofit (Retrofit Android Tutorial using PHP and MySQL).

Issue: Call<DefaultResponse> call = RetrofitClient .getInstance() .getApi() .createUser(email, password, name, school); Log.d(TAG,"Calling call.enqueue of MainActivity(userregister)"); call.enqueue(new Callback<DefaultResponse>() { @Override public void onResponse(Call<DefaultResponse> call, Response<DefaultResponse> response) { Toast.makeText(MainActivity.this,"Present in onResponse of MainActivity",Toast.LENGTH_LONG).show(); DefaultResponse dr = response.body(); //Toast.makeText(MainActivity.this,response.body(),Toast.LENGTH_LONG).show(); //Log.i(TAG,"I'm in failure function"+ dr.getMessage()); //Toast.makeText(MainActivity.this, dr.getMessage(),Toast.LENGTH_LONG).show(); //if(response.code() == 201){ // Toast.makeText(MainActivity.this, "201 return successfully" ,Toast.LENGTH_LONG).show(); //}else if(response.code()==422){ Toast.makeText(MainActivity.this, dr.getMessage(),Toast.LENGTH_LONG).show(); //} Log.d(TAG,"I'm in onResponse function"); } @Override public void onFailure(Call<DefaultResponse> call, Throwable t) { Toast.makeText(MainActivity.this,"I'm in onFailure method of MainActivity",Toast.LENGTH_LONG).show(); Toast.makeText(MainActivity.this,t.getMessage(),Toast.LENGTH_LONG).show(); Log.i(TAG,"I'm in failure function"+ t.getMessage()); Log.d(TAG,"I'm in onFailure function"+ t.getMessage()); } createUser function call successfully and also insert data in database. But JSON Response not fetching.

Whenever I want to show json response using dr.getMessage() App Crash

Shahriaryusuf commented 5 years ago

hello i have created the change info, but its saying that the field ID is missing for updateUser