As the title, I got some problem when trying to automate response google forms type collect submitter data but I am not the form's owner Here is the form: Sample Form
Below is my scratch code in GAS:
function submitToGoogleFormWithEmail() {
var formUrl = "https://docs.google.com/forms/d/e/1FAIpQLSdBdRIYCAaxp2FI4n0rVZywcz0Br7n2DOBOIcWSLHP9B67ikA/formResponse";
var email = Session.getActiveUser().getEmail();
var token = ScriptApp.getOAuthToken();
Logger.log(token);
var payload = {
"entry.1507679348": "lucasdo",
"entry.21751216": "dnd",
"entry.528181198": "appscript",
"emailAddress": email
};
var options = {
'method': 'post',
"muteHttpExceptions": true,
'payload': payload,
'headers': {
'Authorization': 'Bearer ' + token,
'Accept': 'application/x-www-form-urlencoded'
}
};
var response = UrlFetchApp.fetch(formUrl, options);
Logger.log(response.getResponseCode());
}
When I test the code, it showed error code 401 in console log of app script. Console Log Screenshot
I tried with browser console fetching, it worked if I logged in before and go to below url: https://docs.google.com/forms/d/e/1FAIpQLSdBdRIYCAaxp2FI4n0rVZywcz0Br7n2DOBOIcWSLHP9B67ikA/formResponse?entry.1507679348=lucasdo&entry.21751216=dnd&entry.528181198=appscript&[email protected]
Similar thread but not helpful so much: How to auto submitting in require sign-in google form from google apps script
Does anyone have the solution for this case?
1)
they are required to login to Google and2)
they are required to physically check the box with the text " Record <<google email address>> as the email to be included with my response. This email address is subsequently catted and passed to a linked spreadsheet BUT when one looks at the "items" in the Form, the "Email address" is not an accessible item. In short, you are trying to update a field that doesn't exist.