缺失结束时间的谷歌日历

9

这是我的谷歌日历请求。在响应中,错误代码为“缺少结束时间”。我正在尝试使其动态化,因此最终将删除硬编码的开始和结束日期和时间。

var object = {
        "end": {
            'dateTime': "2014-07-28T23:00:00",//end,
            "timeZone": timeZone
        },
        "start": {
            'dateTime': "2014-07-28T18:00:00",//start,
            "timeZone": timeZone
        },
        "calendarId": calendarId,
        "summary": artist,
        "description": description,
        "location": address
    };
    var request = gapi.client.calendar.events.insert(object);

当我在我的Google开发者控制台示例中输入完全相同的内容时,它可以正常工作。 - theB3RV
请访问以下链接以获取与Google日历和Racket Google包中缺少结束时间的问题相关的编程内容:https://stackoverflow.com/questions/37535563/missing-end-time-with-google-calendar-and-racket-google-package?rq=1 - segreb
3个回答

6
这位人提供了答案。 https://groups.google.com/forum/#!msg/google-calendar-api/cnkgXfy_GQQ/SRV1N0TAGtYJ
    var object = {
        'end': {
            'dateTime': '2014-07-28T23:00:00',//end,
            'timeZone': timeZone
        },
        'start': {
            'dateTime': '2014-07-28T18:00:00',//start,
            'timeZone': timeZone
        }
        //'summary': artist,
        //'description': description,
        //'location': address
    };
    var calendarObject =
    {
        'calendarId': calendarId,
        'resource': object
    };
    var request = gapi.client.calendar.events.insert(calendarObject);

1
也许这个错误的原因不是时间错误。也许,日历API无法识别您的JSON。HTTP请求头必须包含“Content-Type: application/json”。请参见此处http://devsplanet.com/question/37535563

@GhostCat 他的观点很中肯......我的"location" 标签里有错误编码,因此谷歌没有读取到结束时间。 - Martin Zvarík

0
这对我有用:
var event = {
      summary: "Google I/O 2015",
      location: "800 Howard St., San Francisco, CA 94103",
      description: "A chance to hear more about Google's developer products.",
      start: {
        date: "2020-05-28"
      },
      end: {
        date: "2020-05-29"
      }
    };

    gapi.client.calendar.events
      .insert({
        calendarId: calendarId,
        resource: event
      })

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接