How do you POST data to a multi-page google form?

烂漫一生 提交于 2019-12-08 08:30:44

问题


I'm trying to auto-fill a google form via POST. However when I actually POST the data to it, only the first pages questions actually get filled.

Example Code:

    private static void PostToFormTest()
    {
        WebClient client = new WebClient();
        var keyValue = new NameValueCollection();
        keyValue.Add("entry.843521592", "Option 1");
        keyValue.Add("entry.901429584", "Test Right Now");
        keyValue.Add("entry.347619935", "Test Page 2");
        Uri uri = new Uri("https://docs.google.com/forms/d/1zuQxyoRUQ-jYwTf7wrPu9Wqln8ec7gfhzRbOILD3LGU/formResponse");
        byte[] response = client.UploadValues(uri, "POST", keyValue);
        string result = Encoding.UTF8.GetString(response);

    }

Responses Sheet:

https://docs.google.com/spreadsheets/d/1B4OSjQRQ37Q5Dt4mxMAx0wx5LfyajvWf_5rCY4lOvBU/edit?usp=sharing

Form:

https://docs.google.com/forms/d/1zuQxyoRUQ-jYwTf7wrPu9Wqln8ec7gfhzRbOILD3LGU/viewform


回答1:


You are posting to a URL that only has 2 of the key value pairs:

// On page #1.
keyValue.Add("entry.843521592", "Option 1");
keyValue.Add("entry.901429584", "Test Right Now");

// On page #2.
keyValue.Add("entry.347619935", "Test Page 2");

The value for the second page cannot be added as the question does not exist when you post to the first page.




回答2:


Add this key in your NameValueCollection.

keyValue.Add("pageHistory", "0,1,2");//Comma separated page indexes (this is for 3 pages`enter code here`)



回答3:


capture all the "entry.#" and then don't foget the pageHistory with total number of pages starting from 0 (like Puneet pointed out)



来源:https://stackoverflow.com/questions/33865480/how-do-you-post-data-to-a-multi-page-google-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!