I am trying to publish some parameters in my rails API using Volley in Android. This is the code:
For Request.Method I tried POST / GET / PUT nothing works.
I tried calling the log statement in getParams (), and it was logged, but the parameters were not 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);
android android-volley
Erdnuss
source share