I make a script to generate a form with data from my server, and deploy it as a web app. The script is in a google standard project, and is in develop status with specific user specified for testing. Proper scopes are indicated, and the user's credentials are successfully generated. Following the guide for "execute a function", however, I always got error: {"error": {"code": 404, "message": "Requested entity was not found.", "status": "NOT_FOUND"}}. Below are my codes:
in the code.js:
function doGet(e){
Logger.log('doGet is called');
var params = JSON.stringify(e);
Logger.log('params: '+params);
var mywork = params.parameters['mywork'];
var formName = params.parameter['formName'];
var subject = params.parameter['subject'];
var result = makeQuestionsForm(mywork, formName, subject);
return ContentService.createTextOutput(JSON.stringify(result))
.setMimeType(ContentService.MimeType.JSON);
}
function doPost(e){
Logger.log('doPost is called');
var params = JSON.stringify(e);
Logger.log('params: '+params);
var mywork = params.parameters['mywork'];
var formName = params.parameter['formName'];
var subject = params.parameter['subject'];
var result = makeQuestionsForm(mywork, formName, subject);
return ContentService.createTextOutput(JSON.stringify(result))
.setMimeType(ContentService.MimeType.JSON);
}
function makeQuestionsForm(mywork, formName, subject) {
// code for generating the form
}
My code calling the script:
service = build('script', 'v1', credentials=self.creds)
parameters = {'mywork':self.sheet_body,'subject':request.session['subject'],'formName':title}
api_request = {
"function": "doPost",
"parameters": parameters,
"devMode": True
}
response = service.scripts().run(body=api_request,
scriptId=SCRIPT_ID).execute()
I did many tries: specifying function as 'doPost', 'doGet', or 'makeQuestionsForm', specifying scriptId as the id of project or id of script. All got the "NOT_FOUND" result.
Alternatively, I tried urlopen method directly calling the script's url, with token provided at request header. Got not-authorized.
Can you help see, what I did wrong or missed? Thanks