I have written GAE cloud endpoint APIs and have successfully deployed them to App Engine. The APIs run successfully locally as well as after deployment on App Engine.
After generating cloud endpoints, i tried to call one of the APIs in my Android client and it throws "GoogleJSONResponseException 404 not found" exception. In the API method, I am using HttpURLConnection and JAXB unmarshaller to call a URL and unmarshall the XML response. The code is as follows:
String uri=<some url>;
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/xml");
JAXBContext jc = JAXBContext.newInstance(MyResponse.class);
InputStream xml = connection.getInputStream();
response = (MyResponse) jc.createUnmarshaller().unmarshal(xml);
connection.disconnect();
Why does this not work only when trying to call from the android client using the endpoint client library? Am i doing something wrong?
Note: I called another API in the same android client which just inserts data into the datastore and it works fine
The LogCat console looks as follows:
06-17 11:44:49.081: W/System.err(2035): com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
06-17 11:44:49.081: W/System.err(2035): Not Found
06-17 11:44:49.081: W/System.err(2035): at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:111)
06-17 11:44:49.081: W/System.err(2035): at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:38)
06-17 11:44:49.081: W/System.err(2035): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:314)
06-17 11:44:49.081: W/System.err(2035): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1060)
06-17 11:44:49.081: W/System.err(2035): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:412)
06-17 11:44:49.081: W/System.err(2035): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:345)
06-17 11:44:49.081: W/System.err(2035): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:463)
06-17 11:44:49.081: W/System.err(2035): at com.niru.i_collect.RegistrationActivity$FindAddressTask.doInBackground(RegistrationActivity.java:296)
06-17 11:44:49.081: W/System.err(2035): at com.niru.i_collect.RegistrationActivity$FindAddressTask.doInBackground(RegistrationActivity.java:1)
06-17 11:44:49.081: W/System.err(2035): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-17 11:44:49.081: W/System.err(2035): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-17 11:44:49.081: W/System.err(2035): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-17 11:44:49.081: W/System.err(2035): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-17 11:44:49.081: W/System.err(2035): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-17 11:44:49.081: W/System.err(2035): at java.lang.Thread.run(Thread.java:856)