0

I tried to login my account by using UrlFetchApp, when I ran script manually, everything worked well. But when I set trigger to run automatically, it returned "error_need_ivs". I have no idea what it is and how to fix. please help me. Below is my code

function login() {
 var data = {
'username':'username',
'password_hash':'password',
}

var option = {
  muteHttpExceptions: true,
  "method" : "POST",
  "payload" : data,
}
var url = 'my url'
var res = JSON.parse(UrlFetchApp.fetch(url,option).getContentText());  
Logger.log(res) //returned error_need_ivs when I set trigger but worked well when I ran script manually
}

UPDATE : This picture show the result after scripting executed by trigger enter image description here

Mike
  • 53
  • 1
  • 8
  • About `But when I set trigger to run automatically, it returned "error_need_ivs".`, there are several triggers in Google Apps Script. What kind of trigger are you using? – Tanaike Nov 14 '22 at 11:24
  • I tried once a day and once a minute – Mike Nov 14 '22 at 14:53
  • Can you share more details on how the trigger was created and the setting used? Can you also share the full Exception you can see on the Executions section? – Gustavo Nov 14 '22 at 16:28
  • I created it manually as usual, the setting is time driven - once a minute. It's is not Exception, when I used Logger.log(res), return value : "error_need_ivs". I have no idea what it is – Mike Nov 14 '22 at 16:49
  • Thank you for replying. In your situation, for example, when `=login()` is put to a cell by using your script as a custom function, what result will you obtain? – Tanaike Nov 15 '22 at 03:02
  • I tried as you said, when =login() is put to a cell by using my script as a custom function. It returned empty cell, script ran but returned wrong result that I don't want :( – Mike Nov 15 '22 at 03:17
  • I already updated some more information below. Please help me . Thank you guys – Mike Nov 15 '22 at 04:47
  • Thank you for replying. From `when I ran script manually, everything worked well.` and `I tried as you said, when =login() is put to a cell by using my script as a custom function. It returned empty cell, script ran but returned wrong result`, I'm worried that your situation might be related to [this thread](https://stackoverflow.com/a/63024816). If my understanding is correct, your request might not be able to be run by the time-driven trigger. But, if my understanding was not correct, I apologize. – Tanaike Nov 15 '22 at 05:55
  • Thank you for your answer. I tried to use changing sheet to activate trigger but it returned same error :((( – Mike Nov 15 '22 at 09:03

1 Answers1

0

From the new screenshot shared I can see no Exceptions were thrown, which means the error logged error_need_ivs certainly comes from the response of the HTTP request rather than an issue with Apps Scripts.

Regarding why it works when calling the affected function manually and why it doesn't worked when invoking it via timed-trigger, I believe what @Tanaike suggested to make sense, maybe the affected endpoint is not prepared to receive IPv6 requests or require more data when doing so.

I'd suggest checking the documentation for the endpoint you are making the request for to help identify what might be causing this behavior.

Alternatively, I'd also suggest to report it as an Issue on IssueTracker using this template. Make sure to include a full reproducible scenario when reporting it (including a working endpoint).

Gustavo
  • 639
  • 2
  • 4