Error using Volley on Android 6

0

When making a request using volley in Android 6 gives this error:

java.net.ProtocolException: Unexpected status line: <?xml version="1.0" encoding="UTF-8"?>

But if I try it in Android 7 works perfectly. I am using a api created in espocrm .

Code:

RequestQueue queue = Volley.newRequestQueue(this);

// Request a string response from the provided URL.
        StringRequest stringRequest = new StringRequest(Request.Method.DEPRECATED_GET_OR_POST, urlCorreosEnModulo,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        // Display the first 500 characters of the response string.
                        //mTextView.setText("Response is: "+ response.substring(0,500));
                        Log.e("response",response);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //mTextView.setText("That didn't work!");
                Log.e("error",error.getCause().toString());
            }
        }){
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<>();
                String credentials = nombreUsuarioESPOCRM+":"+contrasenaESPOCRM;
                String auth = "Basic "
                        + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", auth);
                return headers;
            }
        };

// Add the request to the RequestQueue.
        queue.add(stringRequest);
    
asked by Esteban Moine 07.04.2018 в 00:35
source

0 answers