Skip to content Skip to sidebar Skip to footer

Android Retrofit 2.0 JSON Document Was Not Fully Consumed

I am using retrofit 2.0 to post data in the form of post request with pojo class and returning string as an response either failure or success and now the problem is that it says j

Solution 1:

Also I found out that order also needs to be same with ScalarsConverterFactory.create

    .addConverterFactory(ScalarsConverterFactory.create()) //important
    .addConverterFactory(GsonConverterFactory.create(gson))

It wont work if GSON is on top like following :

    .addConverterFactory(GsonConverterFactory.create(gson))
    .addConverterFactory(ScalarsConverterFactory.create()) //important

Solution 2:

try adding .addConverterFactory(ScalarsConverterFactory.create()) when creating Retrofit object.

Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(Allconstants.MAIN_URL)
      .client(client)
      .addConverterFactory(ScalarsConverterFactory.create())
      .build();

You'll also need to add following to your build.gradle (using version of retrofit you indicated you were using)

   implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'

Post a Comment for "Android Retrofit 2.0 JSON Document Was Not Fully Consumed"