Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I'm writing a script to automate data entry for google forms using a google sheet.

methuna thayalan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 25, 2020

function auto_data() {

var formURL="https://docs.google.com/forms/d/e/1FAIpQLSfB4NZHDqagGZDSyAmn0prmCThgRgp44ED7TsQDbrdvPCL9-A/viewform?usp=sf_link";

var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
var wrkSht = wrkBk.getSheetByName("Sheet1");

var stunumber = wrkSht.getRange("A2").getValue();
var firstn = wrkSht.getRange("B2").getValue();
var lastn = wrkSht.getRange("C2").getValue();
var cohort = wrkSht.getRange("D2").getValue();
var teacher = wrkSht.getRange("E2").getValue();

var datamap = {"entry.1349037061":stunumber,
"entry.115259800":firstn,
"entry.1390558599":lastn,
"entry.245609341":cohort,
"entry.1444620207":teacher};

var options = {
"method": "post",
"payload" : datamap
};

UrlFetchApp.fetch (formURL,options);
}

------------------------------------------------------------------------

when executing the script, I receive this error message:

Exception: Request failed for https://docs.google.com returned code 405. Truncated server response: <!DOCTYPE html>

Does anyone know how to solve this error? it was working fine last night :(

1 answer

0 votes
Hana Kučerová
Community Champion
November 26, 2020

Hi @methuna thayalan ,

welcome to the Atlassian Community!

Error 405 means "Method Not Allowed" - it is not possible to send POST request to the url provided in the script.

I think you are not using correct url. According to the article, it should probably look like this:

https://docs.google.com/forms/d/e/1FAIpQLSfB4NZHDqagGZDSyAmn0prmCThgRgp44ED7TsQDbrdvPCL9-A/formResponse

But please be aware I didn't test it.

Suggest an answer

Log in or Sign up to answer