Orneslat
Orneslat

Reputation: 51

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?

Upvotes: 0

Views: 367

Answers (1)

Orneslat
Orneslat

Reputation: 51

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) {

Upvotes: 2

Related Questions