Skip to content

JSON document was not fully consumed #1

Description

@codulers

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions