BasinNetwork.performRequest results "Unexpected response code 403 for"
Asked Answered
L

6

7

I have this error:

Volley: [8918] BasicNetwork.performRequest: Unexpected response code 403 for

I'm trying to connect in the serve,r but I can't retrieve anything. When I tried it in a localhost server, it works perfectly.

Locule answered 2/3, 2016 at 3:58 Comment(1)
post your code here.so we can find better solution.Avi
I
6

Solution worked for me:
Check is that link works in browser.
If yes then, add Header User-Agent: "Mozilla/5.0" to your requests. Sending header example in Stackoverflow
Sory for my bad english

Indentation answered 4/10, 2020 at 17:13 Comment(0)
S
2

in C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf

change

require local

to

Require all granted
Smarmy answered 6/4, 2017 at 21:19 Comment(0)
S
1

The 403 Forbidden error is an HTTP status code which means that accessing the page or resource you were trying to reach is absolutely forbidden for some reason.

Make sure you are accessing the correct url.

Selfreproach answered 2/3, 2016 at 4:35 Comment(1)
hi Im using the correct url since im trying to load it in browser and it works fine but when Im accessing it from android app my friend told me to put header but I don't know what to put in the headerLocule
F
1

This is for Headers If You Needed

@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");
    params.put("Access Token", token);
    return params;
}

I hope this helps

Furlani answered 18/6, 2019 at 9:56 Comment(0)
F
0

I got this error when I run my application on the built-in emulator of Android Studio. But when I changed the emulator and used Genymotion, the problem was solved and the application run without any errors.

Floss answered 3/11, 2020 at 16:23 Comment(0)
R
-1

I have also faced the same problem and i have solve it by changing the method name. previously i am try to calling web service with POST method and i have changed to GET method then my problem solved. Try this solution by changing request method.

StringRequest stringRequest = new StringRequest(Request.Method.GET, "YOUR_WEBSERVICE_URL",
    new Response.Listener<String>() {
        @Override
        public void onResponse(String response){}
    },
    new Response.ErrorListener() {
         @Override
         public void onErrorResponse(VolleyError volleyError) {}
    }) {

    @Override
    protected Map<String, String> getParams()
    {
        Map<String, String> params = new HashMap<String, String>();

        return params;
    }
};
stringRequest.setRetryPolicy(new DefaultRetryPolicy(60000,DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
requestQueue.add(stringRequest);
Rochus answered 24/12, 2016 at 9:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.