如何正确使用Google Calendar API的Events.Insert命令? [英] How to use Google Calendar API's Events.Insert command properly?

查看:360
本文介绍了如何正确使用Google Calendar API的Events.Insert命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我一直在使用调用Google API的REST方法。我需要将事件插入到具有我的ID的特定日历中。这是我发送的POST请求:



地址:
https://www.googleapis.com/calendar/v3/calendars/ {calendarID} / events



正文:

 授权:持票人{access_token} 
{
end:{
dateTime:2012 -08-30T12:30:00,
timeZone:America / Chicago
},
开始:{
dateTime:2012-08 -30T14:00:00,
timeZone:America / Chicago
},
summary:EE 306,
colorId:9
kind:calendar#event
}

是我收到的回应:

  {
错误:{
errors:[
{
domain:calendar,
reason:timeRangeEmpty,
message:指定的时间范围为空。,
locationType:parameter,
location:timeMax
}
],
code:400,
message:特定fied的时间范围是空的。
}
}

我不明白我可能做了什么错误。我输入了所有必要的数据,它要求我提供一个参数,该参数甚至不存在于事件中。我也找不到有关这个特定问题的任何文档。有人问我这个问题吗?

我已经完成了自己的大脑损伤。事实证明,我无法找到关于这个问题的任何文件的原因是因为它有多么的愚蠢。



它给我这么一个有趣的原因错误是因为在复制粘贴时我正在测试,所以我翻转了开始和结束时间。因此,我告诉Google日历参加了一个在开始前结束的活动,这通常并不会很顺利。 长话短说,如果您在尝试插入事件时遇到了引用timeMax参数的错误,请检查您的开始和结束时间。


So I've been using the REST method of invoking Google's API. I need to insert events into a particular calendar whose ID I have. This is the POST request I'm sending:

Address: https://www.googleapis.com/calendar/v3/calendars/{calendarID}/events

Body:

Authorization:  Bearer {access_token}
{
 "end": {
  "dateTime": "2012-08-30T12:30:00",
  "timeZone": "America/Chicago"
 },
 "start": {
  "dateTime": "2012-08-30T14:00:00",
  "timeZone": "America/Chicago"
 },
 "summary": "E E 306",
 "colorId": "9"
 "kind": "calendar#event"
}

And this is the response I keep getting:

{
 "error":{
  "errors":[
   {
    "domain":"calendar",
    "reason":"timeRangeEmpty",
    "message":"The specified time range is empty.",
    "locationType":"parameter",
    "location":"timeMax"
   }
  ],
  "code":400,
  "message":"The specified time range is empty."
 }
}

I don't understand what I could possibly be doing wrong. I've entered all necessary data, and it's asking me for a parameter that doesn't even exist for events. I also can't find any documentation out there on this particular problem. Does anyone see something I'm missing?

解决方案

In the midst of asking this question, I face palmed so hard I think I've done myself brain damage. As it turns out, the reason I couldn't find any documentation on this problem was because of how spectacularly silly it was.

The reason it was giving me such a funny error was because in the copy-pasting I was doing to test, I flipped the start and end times. So, I was telling Google Calendars to enter an event that ended before it started, which generally doesn't end too well.

Long story short, if you get an error referring to the "timeMax" parameter while trying to insert an event, check your start and end times.

这篇关于如何正确使用Google Calendar API的Events.Insert命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆