Search code examples
android-volleyprotocolexception

com.android.volley.NoConnectionError: java.net.ProtocolException: Unexpected status line: HTTP/1.1 401.3 Unauthorized


The following is my code. I got com.android.volley.NoConnectionError: java.net.ProtocolException: Unexpected status line: HTTP/1.1 401.3 Unauthorized.

    RequestQueue queue = Volley.newRequestQueue(this);
    String url = "http://echo.jsontest.com/key/value/one/two";

    JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, (String)null,
            new Response.Listener<JSONObject>()
            {
                @Override
                public void onResponse(JSONObject response) {
                    Log.e("LOG_VOLLEY","response : "+response.toString());
                    System.out.println(response);
                    txt.setText("response : "+response.toString());
                }
            },
            new Response.ErrorListener()
            {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.e("LOG_VOLLEY", "Error : " + error.toString());
                    System.out.println(error);
                    txt.setText("Error : " +error.toString());
                }
            } );

    queue.add(getRequest);

}

I got a simmilar error when I used the loopj library. This is my first time using volley library and http connect. I appreciate your help. Thank you.


Solution

  • I used your code (removed lines of code relating to TextView) and got the result as the following screenshot (pay attention to the logcat window)

    Volley Get Request