Skip to content

Instantly share code, notes, and snippets.

@vhsu
Created May 28, 2018 16:52
Show Gist options
  • Save vhsu/9d2e8765f0868a54daa781096db221d9 to your computer and use it in GitHub Desktop.
Save vhsu/9d2e8765f0868a54daa781096db221d9 to your computer and use it in GitHub Desktop.
Submit a Google Form from App Script (Google Spreadsheet)
//https://stackoverflow.com/questions/20410497/use-app-scripts-to-open-form-and-make-a-selection?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
// Simulate POST to form
function sendHttpPost() {
// Copy the entire URL from <form action>
var formAction = "https://docs.google.com/forms/d/e/KEY/formResponse";
var payload = {
"entry.888888888": "6689898", // Number
};
// Because payload is a JavaScript object, it will be interpreted as
// an HTML form. (We do not need to specify contentType; it will
// automatically default to either 'application/x-www-form-urlencoded'
// or 'multipart/form-data')
var options = {
"method": "post",
"payload": payload
};
var response = UrlFetchApp.fetch(formAction, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment