I am trying to post some parameters to my rails API using Volley in Android. This is the code:
For Request.Method i tried POST/GET/PUT nothing works.
I tried to call a log statement in the getParams() and it was logged, but the params weren't added to the URL.
StringRequest sr = new StringRequest(Request.Method.GET, Links.URL_login, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
Log.d(TAG, "" + error.getMessage() + "," + error.toString());
}
}){
@Override
protected Map<String,String> getParams(){
Log.d(TAG, "called?");
Map<String, String> params = new HashMap<String, String>();
params.put("email", "daniel");
params.put("pw", "123");
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> headers = new HashMap<String, String>();
headers.put("Content-Type","application/x-www-form-urlencoded");
headers.put("abc", "value");
return headers;
}
};
MySingleton.getInstance(getApplicationContext()).addToRequestQueue(sr);
Volley not calling getParams()
. Please change your subject as they are called as you saw for yourself. – Eucaine