I have an Android app and I'm trying to send a GET request to my Ruby server and I'm using the Volley Library for it.
My Activity has the following code:
UserController.findUser(Utils.URL_findUser + userEmail, new ServerCallback() {
@Override
public void onSuccess(JSONObject result) {
//do something
}
@Override
public void onFailure(VolleyError error) {
//do something
}
});
The method findUser:
public static void findUser(String URL, final ServerCallback callback) {
JsonObjectRequest objectRequest = new JsonObjectRequest(Request.Method.GET, URL, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
callback.onSuccess(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
callback.onFailure(error);
}
});
MySingleton.getInstance().addToRequestQueue(objectRequest);
}
The server receive the request, like this:
Started GET "/users/test@gmail.com" for 127.0.0.1 at 2017-11-24 16:32:49 -0200
Processing by UsersController#show as HTML
Parameters: {"email"=>"test@gmail.com"}
User Load (2.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "test@gmail.com"], ["LIMIT", 1]]
{"controller"=>"users", "action"=>"show", "email"=>"test@gmail.com"}
Completed 200 OK in 17ms (Views: 1.0ms | ActiveRecord: 2.3ms)
But the Response.Listener and Response.ErrorListener is never called.
My function in Rails:
def show
render :json => @usuario
end
I have no idea about what is happening because no error message appear. By the way, when I do the same in a browser I receive the anwer.
I'm using Volley because I need sessions management. Someone know if exists another library that can do the same?
UPDATE:
I did the same with OkHttp Library and it worked. But I really would like to use the Volley and understand why this is happening