How to make a JSON request in volley where I need to send an authentification header and JSON object in body and I expect only an status code 200 answer
JsonObjectRequest request = new JsonObjectRequest(
method,
url,
myJsonObject,
responseListener,
errorListener) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
String creds = String.format("%s:%s", login, password);
String auth = "Basic " + Base64.encodeToString(creds.getBytes(), Base64.DEFAULT);
headers.put("Authorization", auth);
return headers;
}
};
new Response.Listener<String>(){
@Override
public void onResponse(String response) {
Toast.makeText(getActivity(), response, 1000).show();
}
I tried different kinds of response listeners with string or JSON object, object, but always there is an error: android volley org.json.JSONException: End of input at character 0 of
Or is there any other kind of request in volley which supports and json object and authentification header in body and response is just a http status code ?