简体   繁体   English

缺少结束时间 Google 日历

[英]Missing End Time Google Calendar

Here is my google calendar request.这是我的谷歌日历请求。 In the response, the error code is "Missing End Time."在响应中,错误代码是“缺少结束时间”。 I'm trying to make this dynamic, so I will end up removing the hard coded start and end dateTimes.我正在尝试使其动态化,因此我最终将删除硬编码的开始和结束日期时间。

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);

This guy had the answer这个人给出了答案

https://groups.google.com/forum/#!msg/google-calendar-api/cnkgXfy_GQQ/SRV1N0TAGtYJ 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);

Probably, the reason of this error not wrong time.可能,这个错误的原因不是错误的时间。 Probably, Calendar API can't recognize you json.可能,日历 API 无法识别您的 json。 Header of http-request MUST contain "Content-Type: application/json". http-request 的头部必须包含“Content-Type: application/json”。 See here http://devsplanet.com/question/37535563见这里http://devsplanet.com/question/37535563

This worked for me:这对我有用:

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
      })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM