Volley Post Request without param (Header Authentication)

48 views
Skip to first unread message

khairul islam

unread,
Mar 20, 2018, 8:38:27 AM3/20/18
to Volley Users
Is it possible to make a post request without parameters for header authentication?

Here is my code: 

StringRequest request = new StringRequest(Request.Method.POST, BASE_URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if (!response.equals(null)) {
// do something
}
}

}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("tttt ", error.toString());
}
}) {

//This is for Headers If You Needed
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/json; charset=UTF-8");
params.put("Key", "Value");
return params;
}
};
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
queue.getCache().clear();
queue.add(request);
Reply all
Reply to author
Forward
0 new messages