Closed moonandroid closed 8 years ago
Use .string()
not .toString()
.
Sorry but there are no method with .string() for response.body() Please help me here. It's too urgent for me. Thanks in advance
FYI : I'm using 2.0.2 api.
OkHttp's ResponseBody type has a .string() method.
On Fri, Jun 10, 2016 at 1:33 AM moonandroid notifications@github.com wrote:
Sorry but there are no method with .string for response.body() Please help me here. It's too urgent for me. Thanks in advance
FYI : I'm using 2.0.2 api.
— You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/square/retrofit/issues/1851#issuecomment-225097037, or mute the thread https://github.com/notifications/unsubscribe/AAEEEXdkxucKgi6FCv6U-zA2VT5PuODKks5qKPcjgaJpZM4IyCmZ .
Thanks man for quick reply but,
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new OkHttpClient.Builder().addInterceptor(interceptor).build();
if (retrofit==null) {
retrofit = new Retrofit.Builder()
.baseUrl(MAIN_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
}
return retrofit;
}
Call<Responsee> loginUser(@Field("login_type") String login_type, @Field("email") String email,
@Field("password") String password, @Field("deviceID") String deviceID,
@Field("push_token") String push_token, @Field("platform") String platform);
ApiInterface apiService =
ApiClient.getLogin().create(ApiInterface.class);
Call
call.enqueue(new Callback<Responsee>() {
@Override
public void onResponse(Call<Responsee> call, Response<Responsee> response) {
int statusCode = response.code();
Log.e("Tag","onResponse response "+response.body().toString());
**I need response here,which displaying OkHttp log.**
}
@Override
public void onFailure(Call<Responsee> call, Throwable t) {
Log.e("Tag","onResponse onFailure" );
}
});
D/OkHttp: <-- 200 OK http://xx.xx.xx.x/Taxi/wp-content/plugins/xxxxx/webservices/login.php (244ms) D/OkHttp: Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 D/OkHttp: Pragma: no-cache D/OkHttp: Content-Type: text/html; charset=UTF-8 D/OkHttp: Expires: Thu, 19 Nov 1981 08:52:00 GMT D/OkHttp: Server: Microsoft-IIS/7.5 D/OkHttp: X-Powered-By: PHP/5.6.0 D/OkHttp: Set-Cookie: PHPSESSID=pjuhm3cfnbrd6a10a2lnqu9a61; path=/ D/OkHttp: X-Powered-By: ASP.NET D/OkHttp: Date: Fri, 10 Jun 2016 06:00:36 GMT D/OkHttp: Content-Length: 757 D/OkHttp: OkHttp-Sent-Millis: 1465538560518 D/OkHttp: OkHttp-Received-Millis: 1465538560758 D/OkHttp: {"response":{"status":"success","message":"Successfully log in.","result":{"id":"6","title":"Miss.","first_name":"John","last_name":"Doe","date_of_birth":"1996-11-11","email":"test@test.com","password":"Test123@","phone_number":"234234","country":"Azerbaijan","language":"Gujrati","street_name":"test","street_number":"test","postal_code":"365601","city":"tt","company_name":"te","company_street_name":"sdg","company_street_number":"st","company_postal_code":"36560","company_city":"amreli","company_country":"","taxi_or_limo":"","passenger":"0","handbegs":"0","is_wheelchair":"","is_animal":"","smoke":"","kids":"","num_of_kids":"0","kids_age":"","rider_created_date":"2016-04-07 10:27:21","rider_updated_date":"2016-04-13 11:14:38","login_type":"Rider"}}} D/OkHttp: <-- END HTTP (757-byte body)
I want to get this response and need to parse, I tried lots but no success yet.
@JakeWharton,Please help here.
Please ask on StackOverflow.
@swankjesse I have asked at stackoverflow but not got success yet. Can you please help me here ?
Too bad. Did you offer a bounty? You might want to hire a consultant to help.
:(
@moonandroid , did you find a way to retreive infos from your logcat, I'm in the exactly same situation?
@moonandroid Retrofit2DemoActivity
this demo maybe help you !
/OkHttp: <-- 200 OK OkHttp: {"response":{"status":"success","message":"Successfully log in.","..........
But in Log.i("RAW MESSAGE", response.body().toString()); have no value how to get reponse string from public void onResponse(Call call, Response response)