Google App Script - Fetch address unavailable when run as a trigger

时间:2016-04-07 10:42:21

标签: javascript google-apps-script

I have written a google script to get client phone numbers in from the Pipeline Deals api: https://api.pipelinedeals.com/api/v3/people.json?attrs=total&search_id=SEARCH_ID&api_key=API_KEY

It runs fine if I manually run the function, however if I set it up as a time based trigger it returns 'address unavaliable' and errors the script.

// Fetch url data and return parsed JSON or false
function getJSON(object, params){
  try {
    var res = UrlFetchApp.fetch( getUrl(object, params), {method: "GET"} );
    if( !serverResponse(res) ){
      return false;
    }
    return JSON.parse(res.getContentText());
  } catch(e) {
    MailApp.sendEmail(EMAIL, 'Google App Scripts: Get JSON Error', e+'<br/>'+getUrl(object, params) );
  }
}

I have posted above the part of the code that is causing the error, does anyone know if there is a way to make this work?

0 个答案:

没有答案