I am using retrofit1 old style
@GET("/loginUser")
public Call<Response> login(
@Query("email") String email,
@Query("password") String password,
Callback<Response> callback);
Now i don't want to get "User" class however i want to get a String response.
Previously we were using "Response" However there is no Response in retrofit2,
How can i get string response or full body response from the server without using any json parsing?
ScalarsConverterFactory above GsonConverterFactory
Create this class
use it with
EDIT: You have to define it as
There is no callback supported in retrofit2 so you have to remove that. To make it asynchronous, you have to do
EDIT The above code was for retrofit2 beta 3. For retrofit:2.1.0, you have to create ToStringConverterFactory as -
GOOD TO KNOW: Incase you want to have multiple converters (e.g. a String converter as shown above and also a GSON converter):
Make sure you specify the special-purpose converters first (e.g. String converter) and general converters (like Gson) last!
Converters will be called by the order they have been added, if a converter consumed the response, the follwoing converters will not be called.
Retrofit 2.0.0-beta3 adds a converter-scalars module provides a Converter.Factory for converting String, the 8 primitive types, and the 8 boxed primitive types as text/plain bodies. Install this before your normal converter to avoid passing these simple scalars through, for example, a JSON converter.