Google Calendar API 400错误

nil*_*tti 8 api google-calendar-api

我正在尝试在Google Calendar API上执行简单的freebusy查询.我的授权一切工作正常,可以查看用户日历列表等.当我尝试提交忙/闲查询时,我得到400错误(据我所知)没有关于它的详细信息不喜欢.

在我自己的代码和使用Google Calendar API"试用"功能时都是如此.

这是我的请求(使用Try It小部件创建)和响应:Request

POST https://www.googleapis.com/calendar/v3/freeBusy?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZTr-2wksEvp0iGPTnHTirTIItib5WwxmSAySq1ghfI98Cz88kA
X-JavaScript-User-Agent:  Google APIs Explorer

{
     "items": [
          {
              "id": "[my calendar id goes here]@group.calendar.google.com"
          }
     ],
     "timeMin": "2012-01-31T09:00:00",
     "timeMax": "2012-01-31T10:00:00",
     "timeZone": "GMT"
}

Response


400 Bad Request

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  122
content-type:  application/json; charset=UTF-8
date:  Sun, 16 Jun 2013 13:08:32 GMT
expires:  Sun, 16 Jun 2013 13:08:32 GMT
server:  GSE

{
     "error": {
     "errors": [
          {
              "domain": "global",
              "reason": "badRequest",
              "message": "Bad Request"
           }
     ],
    "code": 400,
    "message": "Bad Request"
     }
}
Run Code Online (Sandbox Code Playgroud)

我认为它可能与dateTime对象/格式有关?但我不知道是什么.我真的很感激一些帮助; 一个星期以来,我一直在反对这个!

nil*_*tti 17

好吧,我想出来了,我正在为其他任何对此失去理智的人留下答案.

尽管谷歌的文档说明了这种情况下日期时间的格式,但我可以使用的唯一格式是:

2008-03-07T17:06:02.000Z

这是YYYY-MM-DDTHH:MM:SS.MMMZ

什么是Z?我不知道,但必须在那里.

  • Z是对UTC([协调通用时间(http://en.wikipedia.org/wiki/Coordinated_Universal_Time))时区的简写.坚持不懈的要点. (3认同)