I'm trying to send a POST to a server using loopj's async http library. The following code is pretty standard but I can't get it to work.
I have debugged quite a bit and have checked the following:
- The URL is correct.
- The params are correct and they are stored correctly into the params variable.
It appears that when HttpResponse response = client.execute(request, context);
is called in AsyncHttpRequest.makeRequest()
the request doesn't contain any params:
EDIT : After looking at the code a little more it seems the POST params might be included in the entity or headergroup.
But the real problem is that I don't get any of the callbacks (see code below). The if
statement after the client.execute()
call never gets called (the breakpoint isn't triggered).
RequestParams params = new RequestParams();
params.put("loginid", "user");
params.put("password", "pass");
params.put("deviceid", "deviceid");
AsyncHttpClient client = new AsyncHttpClient();
client.post(MDSettings.BASE_URL + "/user/login", params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Log.d(MDSettings.TAG, "MDConnectionManager - login - response: " + response);
singleton.connectionSuccessful(response, returnIndex);
}
@Override
public void onFailure(Throwable error, String content) {
Log.d(MDSettings.TAG, "MDConnectionManager - login - content: " + content);
singleton.connectionFailed("Login Failed", error.getMessage(), returnIndex);
}
});
I'm using this lib because it lets me send files which I'll need later into this project. If there is another lib that does the same thing (and actually works) that'd be fine with me.
My question is: Why don't I get any callbacks and how can I fix this? Tell me when something isn't clear and I'll try to explain in more depth.