如何将数据发布到多页google表单?

时间:2015-11-23 07:13:59

标签: c# post google-form

我正在尝试通过POST自动填写Google表单。但是,当我实际将数据发布到它时,只有第一页问题实际上被填满了。

示例代码:

    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);

    }

回应表:

  

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

形式:

  

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

3 个答案:

答案 0 :(得分:1)

您要发布到只有2个键值对的网址:

// 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");

无法添加第二页的值,因为当您发布到第一页时问题不存在。

答案 1 :(得分:0)

将此键添加到NameValueCollection中。

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

答案 2 :(得分:0)

捕获所有"entry.#",然后不要欺骗pageHistory,总页数从0开始(如Puneet指出的那样)