I\'m using Retrofit2 and RxJava2CallAdapterFactory
.
The API I consume returns status code always as 200 and for success and response JSON string the JSON st
It seems out that Retrofit's
use of Gson
by default makes it easy to add a custom deserialize to handle the portion of the JSON
document that was the problem.
Sample code
@FormUrlEncoded
@POST(GlobalVariables.LOGIN_URL)
void Login(@Field("email") String key, @Field("password") String value, Callback callback);
getService().Login(email, password, new MyCallback(context, true, null)
{
@Override
public void failure(RetrofitError arg0)
{
// TODO Auto-generated method stub
UtilitySingleton.dismissDialog((BaseActivity>) context);
System.out.println(arg0.getResponse());
}
@Override
public void success(Response arg0, Response arg1)
{
String result = null;
StringBuilder sb = null;
InputStream is = null;
try
{
is = arg1.getBody().in();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
result = sb.toString();
System.out.println("Result :: " + result);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
});