Hello, I'm trying to do a web_services integration with a partner, for php everything worked correctly now I want to implement directly on Android using volley however I'm getting authentication error, here is my code below:
RequestQueue rq = Volley.newRequestQueue(MainActivity.this);
String url = url;
JsonObjectRequest jReq = new JsonObjectRequest(Request.Method.GET, url,null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject2) {
try {
if (jsonObject2 != null) {
lista.add(jsonObject2.toString());
adapter.notifyDataSetChanged();
} else {
Log.i("MaintActivity", jsonObject2.toString());
}
} catch (Exception e) {
Log.i("MaintActivity", e.getMessage().toString());
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
if (volleyError != null) {
Log.i("MaintActivity", volleyError.getMessage().toString());
}
}
}) {
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put("ws_key",ws_key);
params.put("ws_user",ws_user);
params.put("username",username);
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
return params;
}
};
jReq.setRetryPolicy(new DefaultRetryPolicy(
5000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
)
);
rq.add(jReq);
It's worth noting that debugging, the code is only getting into the getHeaders method and does not get through the getParams, does anyone have an idea?
Thank you.