I have a strange glitch where I cannot make the same network call twice.
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
try {
HttpResponse response = client.execute(post, new BasicHttpContext());
The first time I run the network call it works just fine, data is returned. The second time I run the network call (I have run break points through here) it gets to the HttpResponse object, runs the network call, but then immediately jumps to the IOException catch.
the post object has the same data every time, the cookies are all included.
I’m not around anybody knowledgeable about the server (running drupal), but it seems like a server issue.
Can someone shed light on why this would happen? Why would I be prohibited from getting data back a second time?
To shed further light on things, if I break through the response object, I can see it may return "" instead of data. if that helps at all
05-15 11:22:34.612: E/(1094): ObjectService
05-15 11:22:34.612: E/(1094): org.apache.http.client.ClientProtocolException
05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)
05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-15 11:22:34.612: E/(1094): at com.fivepoints.service.ObjectService.getObject(ObjectService.java:121)
05-15 11:22:34.612: E/(1094): at com.fivepoints.model.team.TeamView$ActivityListTask.doInBackground(TeamView.java:94)
05-15 11:22:34.612: E/(1094): at com.fivepoints.model.team.TeamView$ActivityListTask.doInBackground(TeamView.java:1)
05-15 11:22:34.612: E/(1094): at android.os.AsyncTask$2.call(AsyncTask.java:185)
05-15 11:22:34.612: E/(1094): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
05-15 11:22:34.612: E/(1094): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
05-15 11:22:34.612: E/(1094): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
05-15 11:22:34.612: E/(1094): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
05-15 11:22:34.612: E/(1094): at java.lang.Thread.run(Thread.java:1019)
05-15 11:22:34.612: E/(1094): Caused by: org.apache.http.client.CircularRedirectException: Circular redirect to 'http://mysite.com/demoObject/_c'
05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.DefaultRedirectHandler.getLocationURI(DefaultRedirectHandler.java:173)
05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:903)
05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:468)
05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-15 11:22:34.612: E/(1094): ... 10 more
At first the way I was logging errors also caused a crash, so I didn’t know what the exact error was.
The real exception was
Caused by: org.apache.http.client.CircularRedirectExceptionbecause the way the server handles API callsThis is the answer from:
https://stackoverflow.com/a/6699772/727429
HttpClient client = new DefaultHttpClient();client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);