简体   繁体   中英

Upload events to Google API Calendar

I write my app using Google Calendar API. All is ok, but when i try upload repeated events to Google, I have error. I don't know, what is bad.

Code:

EventEntry newEvent = new EventEntry();
newEvent.Title.Text = "Event title";
When time = new When(new DateTime(2013, 02, 12, 15, 0, 0), new DateTime(2013, 02, 12, 17, 0, 0));
newEvent.Times.Add(time);
Where place = new Where();
place.ValueString = "World";
newEvent.Recurrence = new Recurrence();
newEvent.Recurrence.Value = "DTSTART;VALUE=DATE:20130212T15000\r\n" +
                            "DTEND;VALUE=DATE:20130212T17000\r\n" +
                            "RRULE:FREQ=DAILY;BYDAY=Tu;\r\n";
service.Insert(query.Uri, newEvent);

In this, event should be repeated one per week in Tuesday. When I run this, I have error: "Execution of request failed" - but when I comment newEvent.Recurrence.Value..., all is ok, event is in Google Calendar but not repeated :(

Help!

Similar problem solved: How to create "recurData" in Google Calendar?

So create a seperate recurrence

EventEntry myEntry = new EventEntry();
myEntry.Title.Text = "Hello recurring Event!";
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = "here and there";
entry.Locations.Add(eventLocation);

// Any other event properties

// Recurring event:
String recurData =
  "DTSTART;VALUE=DATE:20070501\r\n" +
  "DTEND;VALUE=DATE:20070502\r\n" +
  "RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904\r\n";

Recurrence recurrence = new Recurrence();
recurrence.Value = recurData;
myEntry.Recurrence = recurrence;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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