php - Volley BasicNetwork.performRequest: Unexpected response code 400 -
i creating android project. project created rest api using php slim framework. when opening url of api in browser working fine. see image below.
but when trying send request url (shown in snapshot above) using jsonobjectrequest, getting error in logcat.
e/volley: [397] basicnetwork.performrequest: unexpected response code 400 http://192.168.94.1/myapplication/v1/countrydata
i using following code.
jsonobjectrequest jsonobjectrequest = new jsonobjectrequest(request.method.get, config.url_country_data, new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { toast.maketext(getapplicationcontext(),response.tostring(),toast.length_short).show(); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { toast.maketext(getapplicationcontext(),error.getmessage(),toast.length_short).show(); } }){ @override protected map<string, string> getparams() throws authfailureerror { map<string,string> params = new hashmap<string,string>(); params.put("authorization",config.api_key); return params; } @override public map<string, string> getheaders() throws authfailureerror { map<string,string> headers = new hashmap<string,string>(); headers.put("charset", "utf-8"); headers.put("content-type", "application/x-javascript"); return headers; } }; appcontroller.getinstance().addtorequestqueue(jsonobjectrequest); i searched lot on google , found cconfusing solutions. saying not using header, said don't user header etc etc.
i tried solutions none of them worked far.

Comments
Post a Comment