I get always this 401 error with this code to accept normal authentication. I have add also the file network_security_config.xml to bypass some other info message:
String http_post() {
RequestQueue MyRequestQueue = Volley.newRequestQueue(Library.this);
//String url = "http://" + "hqplayer" + ":" + Utils.password + "@" + Utils.ip + ":8088/library";
String url = "http://" + Utils.ip + ":8088/library";
Log.i(TAG, "HttpPost() <" + url + ">");
MyRequestQueue.add(new StringRequest(Request.Method.POST, url,
new response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.i(TAG, "HttpPost() - onResponse() ");
}},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i(TAG, "HttpPost() - onErrorResponse() ");
Log.i(TAG, "HttpPost() error <" + error + ">");
}}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> params = new HashMap<String, String>();
String creds = String.format("%s:%s","hqplayer","valvole");
String auth = "Basic " + Base64.encodeToString(creds.getBytes(), Base64.DEFAULT);
params.put("Authorization", auth);
return params;
}});
return null;
}