如何将数据POST到多页谷歌表单中
本文关键字:谷歌 表单 数据 POST | 更新日期: 2023-09-27 18:23:57
我正在尝试通过POST自动填写谷歌表单。然而,当我实际将数据发布到它时,实际上只有前几页的问题被填满了。
示例代码:
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
将此键添加到NameValueCollection中。
keyValue.Add("pageHistory", "0,1,2");//Comma separated page indexes (this is for 3 pages`enter code here`)
您发布到的URL只有两个键值对:
// 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");
无法添加第二页的值,因为在发布到第一页时问题不存在。
捕获所有"entry.#"
,然后不要混淆pageHistory
,总页数从0开始(如Puneet所指出的)