小编Mat*_*man的帖子

Google Apps脚本和外部API

如果我没有记错,根据UrlFetch文档,我应该可以在Google Apps脚本中调用New Basecamp API.我怀疑我的混淆来自格式化GAS错误(以及我刚刚开始这一切的事实).我用Google搜索了很久.这就是我所拥有的以及从GAS返回的错误:

GAS中的myCode:

function myFunction() {
  var url = "https://basecamp.com/******/api/v1/projects.json";
  var headers = {
                 "contentType": "application/json",
                 "headers":{ "User-Agent": "MY_APP_NAME",
                            "username:password" : "user:pass"},
                 "validateHttpsCertificates" :false
                 };

var response = UrlFetchApp.fetch(url, headers);
var text = response.getResponseCode();
Logger.log(text);
}
Run Code Online (Sandbox Code Playgroud)

GAS错误消息:

Request failed for https://basecamp.com/2166446/api/v1/projects.json returned code 401.
Server response: HTTP Basic: Access denied. (line 9, file "Code")
Run Code Online (Sandbox Code Playgroud)

我希望这是一个合理的问题,谢谢你的帮助.

api https basecamp google-apps-script

8
推荐指数
1
解决办法
4852
查看次数

Google Apps脚本返回错误的月份(减去1)

在GAS中使用这个简单的脚本:

function testingStuff(){
var date = new Date();
var yr = date.getYear();
var dt = date.getDate();
var mt = date.getMonth();

Logger.log("year: " +yr);
Logger.log("date: " +dt);
Logger.log("month: " +mt);
}
Run Code Online (Sandbox Code Playgroud)

我得到这个作为我的回答:

year: 2013
date: 28
month: 2
Run Code Online (Sandbox Code Playgroud)

今天是2013年3月28日.我不知道是什么导致了这个错误.有没有人得到这个?或者我做错了什么?

google-apps-script

0
推荐指数
1
解决办法
3819
查看次数

标签 统计

google-apps-script ×2

api ×1

basecamp ×1

https ×1