I'm trying to call a custom API from my android app which will return a JSON object (and as far as I know Retrofit will map that into a desirable data type i.e. String for me in this case, please correct me if I'm wrong). So the problem is that when I try to make the API call, the server doesn't receive anything at all. Not sure how to isolate the error. I have no experience with Retrofit before this.
Also, I'm told to make a post request via body. Not sure what that implies in defining my interface. Any suggestions on that will be much appreciated.
Here's the code for the main activity:
RestAdapter adap = new RestAdapter.Builder().setEndpoint(Endpoint).build();
OnLoginAPI loginAPICalls = adap.create(OnLoginAPI.class);
loginAPICalls.userloginCredentials(userCredentails.get(0), userCredentails.get(1), new Callback<String>() {
@Override
public void success(String APIresponse, Response response) {
status = APIresponse;
}
@Override
public void failure(RetrofitError error) {
status = "API Error";
}
});
return status;
And here's my interface :
public interface OnLoginAPI {
@POST("/v1/login")
public void userloginCredentials(
@Field("username") String username,
@Field("password") String password,
Callback<String> response);
}
Here's the logcat log:
09-20 12:41:27.165 721-802/? W/AlarmManager﹕ FACTORY_ON= 0
09-20 12:41:27.165 721-802/? D/LightsService﹕ [SvcLED] SvcLEDTask
09-20 12:41:27.175 721-803/? D/BatteryService﹕ turn on LED for charging
09-20 12:41:27.185 721-738/? D/SensorManager﹕ registerListener :: handle = 7 name= GP2A Light Sensor delay= 200000 Listener= com.android.server.LightsService$4@4259fcc8
09-20 12:41:27.185 721-738/? D/LightsService﹕ [SvcLED] SvcLEDReceiver::isHappyNight = false
09-20 12:41:27.385 721-802/? D/SensorManager﹕ unregisterListener:: Listener= com.android.server.LightsService$4@4259fcc8
09-20 12:41:27.385 721-802/? D/LightsService﹕ [SvcLED] onSensorChanged::light value = 652.0
09-20 12:41:27.395 721-802/? I/LightsService﹕ fileWriteInt : /sys/class/sec/led/led_lowpower value : 0
09-20 12:41:27.395 721-802/? D/LightsService﹕ setLightLocked is called
09-20 12:41:28.897 183-183/? E/SMD﹕ DCD ON
09-20 12:41:31.900 183-183/? E/SMD﹕ DCD ON