I am developing calendar api client and I have problem with reminder - they do not work...
I create event like this:
Event gEvent = new Event()
{
Summary = "Reminder test",
Location = "Reminder test",
Start = new EventDateTime()
{
DateTime = new DateTime(2014, 12, 14, 21, 0, 0),
},
End = new EventDateTime()
{
DateTime = new DateTime(2014, 12, 14, 22, 0, 0),
},
Reminders = new Event.RemindersData()
{
UseDefault = false,
Overrides = new List<EventReminder>()
{
new EventReminder()
{
Method = "email",
Minutes = 15
},
new EventReminder()
{
Method = "email",
Minutes = 30
},
new EventReminder()
{
Method = "email",
Minutes = 45
},
}
}
};
Event simpleEvent = calService.Events.Insert(gEvent, strCalendarID).Execute();
This code works and in my google calendar GUI is really created my event, but if I click on editing event - I can not see my reminders, there are only default reminders. Why? What I am doing wrong?
Thanks for all answers
Today I attempted send request from code with JSON. My method look like this:
private static void CreateSimpleEvent(string strAccessToken, string strCalendarID, string strApiKey)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("https://www.googleapis.com/calendar/v3/calendars/{0}/events?sendNotifications=false&fields=reminders&key={1}", strCalendarID, strApiKey));
request.Method = "POST";
request.ContentType = "application/json";
request.UserAgent = "TestCalendarApi2";
request.Headers.Add("Authorization", "Bearer " + strAccessToken);
string strJson = @"{
'end': {
'dateTime': '2014-12-19T15:30:00.000Z',
'timeZone': 'Europe/Prague'
},
'start': {
'dateTime': '2014-12-19T14:30:00.000Z',
'timeZone': 'Europe/Prague'
},
'reminders': {
'useDefault': false,
'overrides': [
{
'method': 'email',
'minutes': 13
}
]
}
}";
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(strJson);
streamWriter.Flush();
streamWriter.Close();
var httpResponse = (HttpWebResponse)request.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
}
Method proceeded OK and in google calendar was created event, but reminders are still missing when I use AccessToken from ServiceAccountCredential object :(. When I use AccessToken generated in Apis explorer (https://developers.google.com/apis-explorer/#p/calendar/v3/) - reminders are working. Problem is, that in Apis explorer I must turn on OAuth2 and after that I must grand acess...
Is there any way, how to grand access from code?
Thanks for all answers.