简体   繁体   中英

Exception: Invalid argument: http://[object%20Object] in Google Apps Script trigger. (It's working when I run it manually)

I made a script in Google Apps Script to call an external api. It's all working fine when I run it from the script view and from the UI (Used spreadsheet.addMenu). But now I configured a trigger so the script can run every 24 hours.

The strange thing is, I get an error when the script is scheduled, which is this one:

Exception: Invalid argument: http://[object%20Object]
at accessProtectedResource(Exact auth:43:28)
at getAllInvoicesFromExact(Exact calls:14:15)

The argument should be the endpoint url I'm using. And again, it's working fine when I run it manually.

I would expect that it also should be working when I schedule the same script/function.

Does anyone know how to solve this?

I found the issue.

If you configure a trigger and choose a function with parameters, the first parameter is replaced by a parameter called 'e'.

Fixed it by adding 'e' to the parameters.

Changed

function getAllInvoicesFromExact(next, arr) {

To:

function getAllInvoicesFromExact(e, next, arr) {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM