I'm trying to post data to Google docs from my phone in Android, but whenever I send the request, I get back a strange html (not error) page.
If I copy/paste the same url that I generate on the device into my desktop browser, it works just fine (I'm using Postman so it's not a Post/Get verb error).
My guess is that Google docs is recognizing my device as an Android device and redirecting my request to the Android google docs page. Any way to stop this from happening?
Here is my code:
HttpClient httpclient = new DefaultHttpClient();
try {
HttpPost httppost = new HttpPost("https://docs.google.com/macros/exec?" +
"service=..." +
"&Param1=" + java.net.URLEncoder.encode(param1, "ISO-8859-1"));
Log.v("Request", httppost.getURI().toString());
InputStream localInputStream = httpclient.execute(httppost).getEntity().getContent();
byte bytes[] = new byte[20000];
localInputStream.read(bytes);
Log.e("LOG", new String(bytes));
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
And here is the page I get back:
10-14 14:27:39.749: E/html(15814): <!DOCTYPE html>
10-14 14:27:39.749: E/html(15814): <html lang="en">
10-14 14:27:39.749: E/html(15814): <head>
10-14 14:27:39.749: E/html(15814): <meta charset="utf-8">
10-14 14:27:39.749: E/html(15814): <title>Welcome to Google Docs</title>
10-14 14:27:39.749: E/html(15814): <style type="text/css">
10-14 14:27:39.749: E/html(15814): html, body, div, h1, h2, h3, h4, h5, h6, p, img, dl,
10-14 14:27:39.749: E/html(15814): dt, dd, ol, ul, li, table, tr, td, form, object, embed,
10-14 14:27:39.749: E/html(15814): article, aside, canvas, command, details, fieldset,
10-14 14:27:39.749: E/html(15814): figcaption, figure, footer, group, header, hgroup, legend,
10-14 14:27:39.749: E/html(15814): mark, menu, meter, nav, output, progress, section, summary,
10-14 14:27:39.749: E/html(15814): time, audio, video {
10-14 14:27:39.749: E/html(15814): margin: 0;
10-14 14:27:39.749: E/html(15814): padding: 0;
10-14 14:27:39.749: E/html(15814): border: 0;
10-14 14:27:39.749: E/html(15814): }
10-14 14:27:39.749: E/html(15814): article, aside, details, figcaption, figure, footer,
10-14 14:27:39.749: E/html(15814): header, hgroup, menu, nav, section {
10-14 14:27:39.749: E/html(15814): display: block;
10-14 14:27:39.749: E/html(15814): }
10-14 14:27:39.749: E/html(15814): html {
10-14 14:27:39.749: E/html(15814): font: 81.25% arial, helvetica, sans-serif;
10-14 14:27:39.749: E/html(15814): background: #fff;
10-14 14:27:39.749: E/html(15814): color: #333;
10-14 14:27:39.749: E/html(15814): line-height: 1;
10-14 14:27:39.749: E/html(15814): direction: ltr;
10-14 14:27:39.749: E/html(15814): }
... and so on.