Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BasicNetwork.performRequest: Unexpected response code 403 for http://localhost/database/login.php

I am using Volley to connect to MySql database. I created the database tables and wrote the php function and below is the java code. All this was working all along but just yesterday it woke up giving this error in the logcat and its not returning any response, testing the php script using google chrome postman works just fine so im thinking there is something wrong in my java code.

BasicNetwork.performRequest: Unexpected response code 403 for http://192.168.43.71/database/login.php

I know several questions like this have been asked before, i have gone through them all and nothing seems to work at all. I am going nuts.

private void login() {
      StringRequest jsonObjRequest = new StringRequest(Method.POST, Constants.ACCOUNTLOGIN,
              loginSuccessListener(),
              loginErrorListener()) {
      protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
          Map<String, String> params = new HashMap<String, String>();
          params.put("user_phone_number", sPhoneNumber);
          params.put("user_password", sPassword);
          return params;
          };
      }; 
  mVolleyQueue.add(jsonObjRequest);
     }
like image 871
Hopewell Mutanda Avatar asked Feb 21 '15 08:02

Hopewell Mutanda


3 Answers

First check if you can open the same url on your mobile browser. I assume you use Apache2.4.9 webserver. If you've not changed default values for you get "denied permission". To solve this problem you need change some values in "httpd.conf" file which has Apache settings.

1- Under DocumentRoot change Directory xml tag as following:

<Directory />
     AllowOverride none
     Require all granted
</Directory>

2- Under "onlineoffline tag" update the line as following:

<Directory />
    ...
    ...
    ...
#   onlineoffline tag - don't remove
    Require all granted
</Directory>

Note: If you use older version of Apache you need google for right syntax in httpd.conf

Let me know if this changes work or not. :)

like image 107
Soroush Nejad Avatar answered Oct 29 '22 13:10

Soroush Nejad


BasicNetwork.performRequest: Unexpected response code 403 for http://localhost/database/login.php

Here is the problem in the URL, use your system IP where you hosted your web services and disable firewall, antivirus that may sometimes block to access your system services from other.

It may your IP address has changed, confirm it again. Service URL format would be something like http://your_system_ip_address/database/login.php

like image 21
Ajay S Avatar answered Oct 29 '22 15:10

Ajay S


Please check :

  1. Internet permission in your android manifest file.
  2. Check http://localhost/database/login.php on your system browser.

I think it will help.

like image 38
Yogendra Avatar answered Oct 29 '22 14:10

Yogendra