He realizado pruebas con los datos que me entregaste y me funciono de esta manera:
Mi clase ApiClient
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
/**
* Created by Kenji Kawaida on 23-Nov-16.
*/
public class ApiClient {
private static Retrofit retrofit = null;
public static Retrofit getClient(String url) {
OkHttpClient okHttpClient = new OkHttpClient()
.newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.build();
if(url.isEmpty()){
return null;
}
Gson gson = new GsonBuilder()
.setLenient()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
retrofit = new Retrofit.Builder()
.baseUrl(url)
.client(okHttpClient)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
return retrofit;
}
}
La clase ApiInterface
public interface ApiInterface {
@Headers("content-type: application/json")
@POST("login")
Call<UserLoginResponse> login(@Body String jsonObject);
}
La clase de Servicios donde hago el llamado
public class Services {
private Context context;
private ApiInterface apiServices;
private Gson gsonBuilder = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
public Services(Context context, String url){
apiServices = ApiClient.getClient(url).create(ApiInterface.class);
this.context = context;
}
public UserLoginResponse login(Object object) throws IOException {
Call<UserLoginResponse> call = apiServices.login(gsonBuilder.toJson(object));
String url = call.request().url().toString();
UserLoginResponse respuestaWS = respuestaWS = call.execute().body();
return respuestaWS;
}
}
Y por ultimo el Asynctask donde llamo el metodo:
private class Login extends AsyncTask<Void, Void, Void>{
@Override
protected Void doInBackground(Void... voids) {
Services services = new Services(SplashActivity.this, "https://www.jmovil.com/api/auth/");
Usuario usuario = new Usuario();
usuario.email = "jose@fjose.com";
usuario.password = "jose00";
UserLoginResponse userLoginResponse;
try {
userLoginResponse = services.login(usuario);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public class Usuario{
String email;
String password;
}
}
Funciona perfectamente el llamado y realiza el parseo con los datos solicitados