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

南楼画角 提交于 2020-01-07 05:39:13

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/32478222/com-android-volley-noconnectionerror-java-net-protocolexception-unexpected-sta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!