为什么我会从高级日历服务获得"Invalid JSON string"?



我正在尝试从Google Apps脚本调用高级日历服务。我设置了一个我认为非常简单的调用:

  // Retrieve busy info from Calendar API
  var events = Calendar.Freebusy.query({
    timeMin: startDateTime.toISOString(),
    timeMax: endDateTime.toISOString(),
    items: [
      {id: "<Calendar Id>"},
      {id: "<Another Calendar Id>"}
    ]
  });
  var len = events.length;
  Logger.log(len);
  for(var i = 0; i < len; i++) {
    Logger.log(events[i].getTitle());
  }

(显然,我有真正的日历id在我的代码版本。)

但是,当我运行上面的代码时,在第一行就出现了错误。执行记录显示以下错误消息:

[14-07-28 12:41:05:640 EDT] Execution failed: Invalid JSON string: {
 "kind": "calendar#freeBusy",
 "timeMin": "2014-07-28T14:30:00.000Z",
 "timeMax": "2014-08-01T20:00:00.000Z",
 "calendars": {
  "<Calendar Id>": {
   "busy": [
    {
     "start": "2014-07-28T20:00:00Z",
     "end": "2014-07-28T21:00:00Z"
    }
   ]
  },
  "<Another Calendar Id>": {
   "busy": [
    {
     "start": "2014-07-28T17:00:00Z",
     "end": "2014-07-28T17:30:00Z"
    },
    {
     "start": "2014-07-28T18:00:00Z",
     "end": "2014-07-28T20:00:00Z"
    },
    {
     "start": "2014-07-29T12:30:00Z",
     "end": "2014-07-29T14:00:00Z"
    },
    {
     "start": "2014-07-29T15:30:00Z",
     "end": "2014-07-29T17:00:00Z"
    },
    {
     "start": "2014-07-29T23:50:00Z",
     "end": "2014-07-31T01:07:00Z"
    },
    {
     "sta... (line 33, file "Code") [0.837 seconds total runtime]

知道为什么我得到一个"无效的JSON字符串"错误吗?

我想问题在于这个关键元素:"<Calendar Id>""<Another Calendar Id>"。尝试使用序列字符串代替,不使用通常具有特殊含义的<>字符。

相关内容

最新更新