I'm trying to test my apps script doPost function, with postman. so far I have:
function doPost(e) {
var id = '1L_U7MhmV............................'
SpreadsheetApp.openById(id).getSheetByName('responses').appendRow([new Date()]);
var params = JSON.stringify(e.parameter);
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
I can get it working with the /exec string but when I try the /dev string I can't. I'm getting a 500 error. I'm logged into my account and have updated the version number under publish. How can I get this working?
EDIT:
Thank you. I'm trying to option 1. I created a function that logs the oath token:
function getOAuthToken1() {
Logger.log('Current project has ' + ScriptApp.getOAuthToken());
}
https://script.google.com/macros/s/ACCESSTOKEN/dev
but posting to this produces:
Sorry, the file you have requested does not exist.
EDIT2:
doPost()
and access to Web Apps with the endpoint of https://script.google.com/macros/s/###/dev
.If my understanding is correct, https://script.google.com/macros/s/ACCESSTOKEN/dev
cannot be used as the endpoint. Please use the original endpoint of https://script.google.com/macros/s/###/dev
.
As 2 examples for the simple test, when the curl command is used, the sample commands are as follows. You can select one of them and test at your terminal. Both commands use POST method.
curl -L -H "Authorization: Bearer ### access token ###" -d "key=value" "https://script.google.com/macros/s/#####/dev"
or
curl -L -d "key=value" "https://script.google.com/macros/s/#####/dev?access_token=### access token ###"
https://script.google.com/macros/s/###/dev
of the deployed Web Apps, it is required to use the access token.### access token ###
to the value retrieved by ScriptApp.getOAuthToken()
.https://script.google.com/macros/s/#####/dev
to your endpoint retrieved by deploying Web Apps.-d "key=value"
for the post method. If you don't want to put the values, please replace to -d ""
.https://www.googleapis.com/auth/drive
is added.
// DriveApp.getFiles();
getOAuthToken1()
again. By this, the access token including the scope can be retrieved.