znat
znat

Reputation: 13474

Google Cal API - "Missing end time" when inserting an event

I am trying to insert an event in a Google Calendar using the Google Calendar API.

The event resource I am inserting:

{
  "summary": "test",
  "location": "test",
  "description": "test",
  "start": {
    "dateTime": "2015-11-02T10:00:00-05:00",
    "timeZone": "America/Toronto"
  },
  "end": {
    "dateTime": "2015-11-02T11:00:00-05:00",
    "timeZone": "America/Toronto"
  },
  "attachments": [
    {
      "fileUrl": ""
    }
  ],
  "attendees": [
    {
      "email": "[email protected]"
    },
    {
      "email": "[email protected]"
    }
  ],
  "reminders": {
    "useDefault": false,
    "overrides": [
      {
        "method": "email",
        "minutes": 1440
      },
      {
        "method": "popup",
        "minutes": 10
      }
    ]
  }
}

This event is sent as the body of a POST request to https://www.googleapis.com/calendar/v3/calendars/calendarId/events. I am not using any library.

I consistently get a "missing end time" error. I found a few similar issues such as this one, (s)he is using the Javascript library and suggests to send the following as a body:

{
    resource:<event above>,
    calendarId:<calendarId>
}

But this did not work in my case, perhaps because I don't use a library. I dont't think it matters, but I am doing this inside a Meteor app. Any idea?

EDIT Turns out it was a meteor related issue after all. I was making a mistake using their HTTP lib.

Upvotes: 4

Views: 1075

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116908

This event is sent as the body of a POST request to https://www.googleapis.com/calendar/v3/calendars/calendarId/events.

not sure if that's a type-o or not but I sent a request using try me and your dates and it works I posted to my primary calendar

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

its not calendarId the string its the id of the calendar you want to insert to. you also have to add the access token on the end.

What I sent

POST https://www.googleapis.com/calendar/v3/calendars/primary/events?key={YOUR_API_KEY}
{
 "end": {
  "dateTime": "2015-11-02T11:00:00-05:00",
  "timeZone": "America/Toronto"
 },
 "start": {
  "dateTime": "2015-11-02T10:00:00-05:00",
  "timeZone": "America/Toronto"
 },
 "description": "test",
 "summary": "test"
}

Upvotes: 1

Related Questions