3

I'm using Google Calendar API for one of my projects.

I want to import events to Google Calendar from my app, and lock them so the final user won't be able to modify them in Google Calendar.

The API works great so far, however, when I try to import an event, I get this error:

The owner of the calendar must either be the organizer or an attendee of an event that is imported.

Even if I set the organizer to be one of the calendar's owners.

Here is the POST sample from the API console:

POST https://www.googleapis.com/calendar/v3/calendars/_my_calendar_id%40group.calendar.google.com/events/import?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZTdiWGywGp2LLSUlc8BV-dVIwJET5azIkNekjNgRjHRWc_Ojg
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "end": {
  "dateTime": "2013-01-02T16:22:00+00:00"
 },
 "iCalUID": "123456789",
 "start": {
  "dateTime": "2013-01-02T14:22:00+00:00"
 },
 "organizer": {
  "email": "_this_is_the_owner@gmail.com",
  "displayName": "Owner Guy"
 },
 "attendees": [
  {
   "email": "_this_is_the_owner@gmail.com"
  }
 ]
}

Steps to reproduce:

  • Create a calendar and get the ID or use "primary" for your primary calendar.
  • Share it with somebody, or make somebody the owner.
  • Go to the Calendar API Reference/events/import -> "Try it!", and use oAuth to authenticate before submitting the POST.
  • Complete the required fields (start, end, icaluid, etc)
  • Try to set the organizer or any attendee as one of the calendar's owners.
Kara
  • 6,115
  • 16
  • 50
  • 57
Pablo
  • 105
  • 2
  • 7

2 Answers2

3

On the error message:

The owner of the calendar must either be the organizer or an attendee of an event that is imported.

IMHO, The owner really means NOT the Google user, but the Email-like Calendar ID you're working on. This explains why some cases work only with the primary calendar, because the primary calendars have the same id with its owner user(xxx@gmail.com).

So, you may try these:

  1. Do not set any organizer-related fields. Then Google sets appropriate values for the fields(either attendees[].organizer or organizer).
  2. Set the calendar ID as an attendee[].email
grampush
  • 31
  • 2
2

From my experiments (I am not aware that this is documented anywhere), you can only 'import' events with attendees to the "primary" calendar in an account (not a sub-calendar). I do not know why this is. Also be aware that 'import' makes a private copy of the event and changes to the event will not be propagated to other attendees (though possibly attendee status will be).

Jas
  • 327
  • 2
  • 9