Volleyball does not call getParams ()

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); 
+1
android android-volley
source share
1 answer

If the server reads as a key-value pair, use this

  Uri.Builder builder = Uri.parse(Links.URL_login).buildUpon(); builder.appendQueryParameter("email", " me@email.com "); builder.appendQueryParameter("pw", "mypwd"); String loginUrl=builder.build().toString(); StringRequest sr = new StringRequest(Request.Method.GET, loginUrl...... 

And @vovaxo said that a GET request never calls the getParams() method.

Happy_Coding;

+3
source share

All Articles