0

I succeed to change and update values in Google Spreadsheet by sending the following request:

https://script.google.com/macros/s/########/exec?action=update&&redname=John&&bluename=Dow

from PC Internet Browser

But sending the same URL from android application is not working. For example the following script doesn't do anything:

BufferedReader reader = null;

StringBuffer buffer = new StringBuffer();

URL url = new URL(request);

HttpsURLConnection connection = (HttpURLConnection) url.openConnection();

connection.setDoOutput(true);

connection.setInstanceFollowRedirects(false);

connection.setRequestMethod("GET");

connection.setRequestProperty("Content-Type", "text/plain");

connection.setRequestProperty("charset", "utf-8");

connection.connect();

I've tried many variants of the code but without success.

Any help is highly appreciated!

Thanks

Lori
  • 1,240
  • 1
  • 21
  • 26
  • In the above code, you don't show how you format your `request` URL! And secondly, how was the web app published i.e. "authorized to run as you" and "anyone even anonymous" access? Also, this [post](https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests) on SO might be useful. – Jack Brown Jan 24 '19 at 23:28
  • @Jack Brown Thanks for your reply. The request consist of 3 key values (parameters) and Google Script URL. Gscript gets the values and performs actions (update) at certain cells in the Spreadsheet. I noticed that when I apply the request from Chrome (where I signed in with google account) it works perfect. But when I apply the request from IE it opens SIGN IN form. Hope this can make the problem clear. – Всеволод Леонтьев Jan 25 '19 at 01:28
  • If you have to log in to run the script, then the above code in android won't work unless you provide the correct authorization. What response do you get when you run the above code? – Jack Brown Jan 25 '19 at 01:37
  • This post covers most issues you have: https://stackoverflow.com/questions/49675989/http-request-with-oauth2-to-google-app-script-web-app – Jack Brown Jan 25 '19 at 01:46

0 Answers0