试图让这个工作。 我在争论列表后继续得到一个失踪者。 (第6行,文件“代码”)解散。 我仔细检查了我的括号,但没有用。 我错过了什么吗?

我希望这是一个合理的问题。 谢谢。

function myFunction() {
  var url = "https://company.harvestapp.com/people";
  var headers = {
    "Accept": "application/xml",
    "Content-Type": "application/xml",
    "Authorization": "Basic " + Utilities.base64Encode(dude@dude.com +":"+pw)
     };
  var response = UrlFetchApp.fetch(url,headers);
  var text = response.getResponseCode();
  Logger.log(text);
}

===============>>#1 票数:3 已采纳

得到它了。 还要感谢Brian。 我终于意识到你需要一个“选项”对象,你传递方法和标题。

function myFunction() {
    var url = "https://swellpath.harvestapp.com/people/";
    var user = "dude@dude.com";
    var password = "supersecurepw";

    var headers = {
        "Accept": "application/xml",
        "Content-Type": "application/xml",
        "Authorization": "Basic "+ Utilities.base64Encode(user+":"+password)
    };

    var options = {
        "method" : "get",
        "headers" : headers 
    };

    var response = UrlFetchApp.fetch(url,options);

    Logger.log(response);
}

===============>>#2 票数:0

编辑:

尝试:

   "Authorization": "Basic " + Utilities.base64Encode("dude@dude.com:"+pw)

===============>>#3 票数:0

可能存在附加错误,但是您的第一个问题是您需要将“标题”对象添加到“选项”对象,然后执行以下操作

    var url = "https://company.harvestapp.com/people";

    var headers = { "Accept": "application/xml",
                   "Content-Type": "application/xml",
                  "Authorization": "Basic " + Utilities.base64Encode(dude@dude.com +":"+pw)
                  };

      var options ={
                    "headers" : headers
                   };
       var response = UrlFetchApp.fetch(url,options);

  ask by Blexy translate from so

未解决问题?本站智能推荐: