Domanda

Trying to get this to work. I keep getting a Missing ) after argument list. (line 6, file "Code")Dismiss. I've double checked my parenthesis, but no avail. Am I missing something?

I hope this is a reasonable question. Thank you.

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);
}
È stato utile?

Soluzione

Got it. Thanks to Brian, too. I finally realized that you need an "options" object where you pass the method and headers.

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);
}

Altri suggerimenti

EDITED:

Try:

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

There might be addtional errors, however your first problem is that you need to add the "headers" object to a "options" object and then do the following

    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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top