4

So I have successfully post data onto a Google Spreadsheet using the Google Form source. Everything works perfect UNTIL I make the field (in the Google Form) "required." When I do that, the Android Emulator still responds as if the information sent was properly saved. But on the Google spreadsheet it isn't there.

Am I missing something?

This is my AsyncTask:

    new BackgroundTask().execute(
                    "https://docs.google.com/forms/d/10QStmb9Nr-hcfv889FMSNTZdA_hNUErxeK7vISzkx0E/formResponse",
                    student.FirstName,  "entry_2030274183=",
                    student.LastName,   "entry_1558758483=",
                    student.Age,        "entry_1871336861=",
                    student.Gender,     "entry.2013677542=",
                    student.Grade,      "entry_1921311866=");

This is my Background.

    protected String doInBackground(String... params) {
        HttpRequest reg = new HttpRequest();
        String URL = params[0];
        String FirstName = params[1];
        String FirstNameEntry = params[2];
        String LastName = params[3];
        String LastNameEntry = params[4];
        String Age = params[5];
        String AgeEntry = params[6];
        String Gender = params[7];
        String GenderEntry = params[8];
        String Grade = params[9];
        String GradeEntry = params[10];
        @SuppressWarnings("deprecation")
        String data = 
                FirstNameEntry + URLEncoder.encode(FirstName) + "&" +
                LastNameEntry + URLEncoder.encode(LastName) + "&" +
                AgeEntry + URLEncoder.encode(Gender) + "&" +
                GenderEntry + URLEncoder.encode(Age) + "&" +                    
                GradeEntry + URLEncoder.encode(Grade);
        String response = reg.sendPost(URL, data);          

        return response;
    }       

Do I need to put something in the entries if it is a required field? If you want to look at the HttpRequest class go here (Not My Code): Secure HTTP Post in Android

Much Appreciated

Community
  • 1
  • 1
  • I'm having the same problem, half the fields are required in the form im using and google does not accept the post. I saved the response to a file and it's just the same form with the "This is a required field" under all of them. – Andrew Senner Sep 23 '14 at 01:44

1 Answers1

1

The only way I can immediately think of is by processing the response and then making your app behave accordingly.

For instance - I tried one test form and if the request send had some required field empty, then the HTTPResponse contains "Looks like you have a question or two that still need attention".

Another way would be to validate if the save was actually successful by searching for the text you gave in the "Confirmation Page".

In both cases, you should be able to differentiate between a successful post and a failed one.

Gurusharan S
  • 345
  • 1
  • 7
  • Instead of putting the logic through the HTTPResponse, I did it through the the application itself. (I thought it would be much easier). However, even when I fill out the whole form myself, it wouldn't send any information to a single field. – Michael Villar Sep 29 '14 at 19:39
  • However, handling it through application might need you to make redundant updates (if you make something mandatory on your form, you'll want to update your app). So thought it would be easier to check the HTTPResponse received. – Gurusharan S Sep 30 '14 at 14:43