Google Calendar API 400错误 [英] Google calendar API 400 error
问题描述
我正在尝试在Google Calendar API上执行一个简单的忙查询.我的授权全部正常,可以查看用户日历的列表等.当我尝试提交忙/闲查询时,出现400错误,(据我所知)根本没有任何细节.不喜欢.
I'm trying to execute a simple freebusy query on the Google Calendar API. I have my authorization all working fine, can see lists of users' calendars, etc. When I try to submit a free/busy query, I get a 400 error with (as far as I can tell) not details at all about what it doesn't like.
在我自己的代码中以及当我使用Google Calendar API的"Try It"功能时,都是如此.
This is true both in my own code and when I use the Google Calendar API "Try It" feature.
这是我的请求(使用Try It小部件创建),以及响应: 请求
Here is my request (created using the Try It widget), and the response: 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"
}
}
我认为这可能与dateTime对象/格式有关?但是我不知道该怎么办.我真的很感谢您的帮助.我已经为此奋斗了一个星期!
I think it might have something to do with the dateTime objects/formatting? But I don't have any idea what. I'd really appreciate some help; I've been banging my head against this for a week!
推荐答案
好,我已经弄清楚了,我将答案留给其他为此失去想法的人.
Ok, I figured it out and I am leaving the answer for anyone else who is LOSING THEIR MIND over this.
尽管在这种情况下Google文档对日期时间格式有何规定,但我唯一可以使用的格式是:
Despite what Google's documentation says about format for datetime in this case, the only format I could get to work was this:
2008-03-07T17:06:02.000Z
2008-03-07T17:06:02.000Z
所以 YYYY-MM-DDTHH:MM:SS.MMMZ
so that's YYYY-MM-DDTHH:MM:SS.MMMZ
Z代表什么?我不知道,但是它必须在那里.
What is the Z for? I don't know, but it has to be there.
这篇关于Google Calendar API 400错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!