简体   繁体   English

HttpClient:错误:com.android.volley.RedirectError

[英]HttpClient: error: com.android.volley.RedirectError

loginBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) 
{

            String userName = editTextEmail.getText().toString().trim();
            String password editTextPassword.getText().toString().trim();
            String LOGIN_URL = "http://www.someurl.com/Rest/AIwebservice/Authenticate?user="+userName+"&password="+password;
            //String uri = String.format("https://www.auruminfo.com/Rest/AIwebservice/Authenticate?user=subhash&password=Subhash");

            //String uri = String.format("https://www.someurl.com/Rest/AIwebservice/Authenticate?user="+userName+"&password="+password);
            StringRequest sr = new StringRequest(Request.Method.GET,LOGIN_URL,
                    new Response.Listener<String>() {
                        @Override
                        public void onResponse(String response) {
                            Log.e("HttpClient", "success! response: " + response.toString());
                        }
                    },new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Log.e("HttpClient", "error: error.toString());
                        }
                    })
            {
                @Override
                protected Map<String,String> getParams(){
                    Map<String,String> params = new HashMap<String, String>();
                    params.put("user","");
                    params.put("password","");
                    return params;
                }
                @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    Map<String,String> params = new HashMap<String, String>();
                    params.put("Content-Type","application/json;charset=UTF-8");
                    return params;
                }
            };
            queue.add(sr);

        }
    });


}

and Log Cat:- 和日志猫:-

08-02 18:17:08.778 7070-7091/com.some.eww.logindemo E/Volley: [9414] BasicNetwork.performRequest: Request at http://www.someurl.com/Rest/AIwebservice/Authenticate?user=&password= has been redirected to https://www.someurl.com/Rest/AIwebservice/Authenticate?user=&password= 08-02 18:17:08.794 7070-7070/com.anghatechsolution.eww.logindemo E/HttpClient: error: com.android.volley.RedirectError 08-02 18:17:08.778 7070-7091 / com.some.eww.logindemo E / Volley:[9414] BasicNetwork.performRequest:在http://www.someurl.com/Rest/AIwebservice/Authenticate?user=上的请求&password =已重定向到https://www.someurl.com/Rest/AIwebservice/Authenticate?user=&password= 08-02 18:17:08.794 7070-7070 / com.anghatechsolution.eww.logindemo E / HttpClient:错误:com.android.volley.RedirectError

I found the issue in my case in String LOGIN_URL = " http://www.someurl.com ; 我在String LOGIN_URL =“ http://www.someurl.com ;

The original API uses HTTPS not HTTP 原始API使用HTTPS而不是HTTP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM