0
votes

I am Using Loopj library to parse json data in my android application but every time response goes in onFailure.

W/JsonHttpRH: onFailure(int, Header[], String, Throwable) was not overriden, but callback was received W/JsonHttpRH: org.apache.http.client.HttpResponseException: Method Not Allowed W/JsonHttpRH: at com.loopj.android.http.AsyncHttpResponseHandler.sendResponseMessage(AsyncHttpResponseHandler.java:466) W/JsonHttpRH: at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:160) W/JsonHttpRH: at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177) W/JsonHttpRH: at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106) W/JsonHttpRH: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) W/JsonHttpRH: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) W/JsonHttpRH: at java.util.concurrent.FutureTask.run(FutureTask.java:137) W/JsonHttpRH: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) W/JsonHttpRH: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) W/JsonHttpRH: at java.lang.Thread.run(Thread.java:856) E/CT: E/CT: E/CT: E/CT: E/CT:
Service

3

3 Answers

0
votes

I think problem is in your URL Putting a '/' at the end of URL causes the redirect to happen because your server likes URLs that end in '/'. POST is fully supported by the URL your server redirects you to, but the client is executing a GET request when it behaves according to your setRedirecting() call (cURL does the same exact thing with the -L switch) The fix is to either put a '/' at the end of URL, or to grab the Location header from the response yourself and then initiate another POST request manually.

This can be observed in wireshark. You can test the theory by trying to perform a GET request with your browser to the URL with a slash appended to it. That will cause the browser to get a 405. Here's the fixed code for Android, this code uses the simple fix of appending a '/' to the URL (not production ready):

or

you forgot to allow your app to access the internet in the manifest. As for the documentation not matching my code's callbacks, the versions may not match because the signatures in the source of my android async 1.4.3 jar are consistent with my overrides.

0
votes

First you check json data i.e coming data is in jsonArray format or only array type. use this method for parse json data

private void parseJSON() {

    try {
        JSONObject josn = new JSONObject(GetCar);

                    JSONArray array = json.getJSONArray("Company");

    } catch (JSONException e) {
        e.printStackTrace();
    }
}
0
votes
Method Not Allowed 

You are trying to make HTTP call with method(POST, PUT) that is not allowed on your server side.