1

I have followed a tutorial on Youtube about how to post data to a Google spreadsheet. It works and I can send words to the spreadsheet. All great, but I need to be able to use select for a true or false question in the spreadsheet. The code I am using:

    public void postData() {

    String fullUrl = "https://docs.google.com/forms/d/1kgVjyzamlIVSkd-BiW5iA-AHkVLqcNf9IxObyNyygTg/formResponse";
    HttpRequest mReq = new HttpRequest();
    String col1 = "Hello";
    String col2 = "World";
    String col3 = "true";
    String data = "entry_221637619=" + URLEncoder.encode(col1) + "&" + 
                  "entry_838953460=" + URLEncoder.encode(col2) + "&" +
                  "entry_1848159036=" + URLEncoder.encode(col3);


    String response = mReq.sendPost(fullUrl, data);
    Log.i(myTag, response);
} 

String col3 is the variable that is using the true or false question. If I remove col3 from this code it will work but since it is a required field it doesn't work. Does anyone know how to do this? Link to the form: http://goo.gl/forms/agGnl39cXT Link to the responses: https://docs.google.com/spreadsheets/d/10Mjbwmlu_C-2OSQmMyS-5_-8GnRQhXw0Dd6_KG5onQM/pubhtml

  • It works correct from my side. There is a process delay when responses to display. So could you tell me more details about how it doesn't work from your side? Thanks. – Dayton Wang Dec 08 '14 at 18:02
  • When I run the exact code shown above, it won't post anything. It was only working for me when the last field was not required and even then it would only upload the first 2 fields, but not the true/false question. – Guus van Walstijn Dec 08 '14 at 18:09
  • But I did see the results correct from the responses link you provided after I filled in the form. Maybe I didn't understand your problem very well. – Dayton Wang Dec 08 '14 at 18:15
  • Can you send your entire application? I haven't changed the code shown above and I can see that it did work for you in the results in the spreadsheet – Guus van Walstijn Dec 08 '14 at 18:22
  • I can fill in the true/false question correct from your link and see the results as well. – Dayton Wang Dec 08 '14 at 18:32
  • Are you using String col3 = "true"; without any capitals? – Guus van Walstijn Dec 08 '14 at 18:48
  • I didn't change any code from your origin one. It just works for me fine. – Dayton Wang Dec 08 '14 at 21:12
  • If you track the network headers when submitting the POST form data is actually sent as `entry.33865771:TRUE`. Personally as you allow a Google Sheet to accept and handle POST (and GET) data as you like I'd look at that as a solution http://stackoverflow.com/q/10000020/1027723 – mhawksey Dec 08 '14 at 23:21

0 Answers0