I need help to create a new event inside Google calendar. I followed this link
and its working fine but now I need to add new event and delete event(existing/new) and I couldn't able to figure out how to add events. I tried this example to insert new events in calendar:link
but when i compile it gives me an error and here is the screen shot.
I will really appreciate help.
To add new event and send invite:
Event myEvent = new Event
{
Summary = "Discussion on new project",
Location = "Mentor",
Start = new EventDateTime()
{
DateTime = new DateTime(2018, 8, 16, 10, 0, 0),
TimeZone = "America/Los_Angeles"
},
End = new EventDateTime()
{
DateTime = new DateTime(2018, 8, 16, 11, 30, 0),
TimeZone = "America/Los_Angeles"
},
Recurrence = new String[] { "RRULE:FREQ=WEEKLY;BYDAY=MO"},
Attendees = new List<EventAttendee>()
{
new EventAttendee() { Email = "abc#gmail.com" }
}
};
var recurringEvent = service.Events.Insert(myEvent, "primary");
recurringEvent.SendNotifications = true;
recurringEvent.Execute();
Related
I can create an event but I can't create an event with a conference.
I tried all these types: "eventHangout" "eventNamedHangout" "hangoutsMeet" but still getting Invalid conference type value
Google.GoogleApiException: 'Google.Apis.Requests.RequestError
Invalid conference type value. [400]
Errors [
Message[Invalid conference type value.] Location[ - ] Reason[invalid] Domain[global]
]
Here's the code that creates and executes an event:
CalendarService service = GetCalendarService();
EventDateTime start = new EventDateTime();
start.DateTime = new DateTime(2021, 02, 19, 18, 47, 0);
EventDateTime end = new EventDateTime();
end.DateTime = new DateTime(2021, 02, 19, 18, 50, 0);
Event newEvent = new Event();
newEvent.Start = start;
newEvent.End = end;
newEvent.Summary = "New event";
newEvent.Description = "description";
newEvent.ConferenceData = CreateConferenceData();
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
request.ConferenceDataVersion = 1;
Event createdEvent = request.Execute();
Here's the code of CreateConferenceData() method:
ConferenceData conferenceData = new ConferenceData()
{
CreateRequest = new CreateConferenceRequest()
{
RequestId = Guid.NewGuid().ToString(),
ConferenceSolutionKey = new ConferenceSolutionKey()
{
Type = "hangoutsMeet" // Change according to your preferences
};
}
};
return conferenceData;
this is my service and worked perfect conference event
_calenarService = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = GenerateCredentials(),
ApplicationName = this._applicationName
});
var myEvent = new Event
{
Summary = "Google Calendar API Testing ",
Location = "Islamabad, Punjab, Pakistan",
Start = new EventDateTime()
{
DateTime = new DateTime(2021, 4, 5, 14, 0, 0),
TimeZone = "Asia/Karachi"
},
End = new EventDateTime()
{
DateTime = new DateTime(2021, 9, 10, 15, 0, 0),
TimeZone = "Asia/Karachi"
},
Recurrence = new String[] { "RRULE:FREQ=WEEKLY;BYDAY=MO" },
//If you want to add attendee
//Attendees = new List<EventAttendee>()
//{
// new EventAttendee { Email = "......com" },
// new EventAttendee { Email = "......." }
//},
ConferenceData = new ConferenceData
{
ConferenceSolution = new ConferenceSolution
{
Key = new ConferenceSolutionKey
{
Type = "hangoutsMeet"
}
},
CreateRequest = new CreateConferenceRequest
{
RequestId = "qwerfsdiob",
ConferenceSolutionKey = new ConferenceSolutionKey
{
Type = "hangoutsMeet"
},
},
EntryPoints = new List<EntryPoint> ()
{
new EntryPoint { EntryPointType = "video" },
}
}
};
var recurringEvent = _calenarService.Events.Insert(myEvent, "primary");
recurringEvent.SendNotifications = true;
recurringEvent.ConferenceDataVersion = 1;
Event eventData = recurringEvent.Execute();
Header 1
The issue was only single user adds the events in google calendar with client id and client key.
But my requirement is multiple users can add events to google calendar when click on link it redirects to google calendar login page. Events details coming from db. I attached my previous code.
string eventName = "Dummy";
DateTime startDate = new DateTime(2020, 04, 28, 16, 30, 00);
DateTime endDate = new DateTime(2020, 04, 28, 17, 00, 00);
string location = null;
startDate = DateTime.SpecifyKind(startDate, DateTimeKind.Local);
endDate = DateTime.SpecifyKind(endDate, DateTimeKind.Local);
string link = "www.sample.in";
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId ="Key",
ClientSecret = "Key",
},
new[] { CalendarService.Scope.Calendar },
"user",
CancellationToken.None).Result;
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = "Calendar API Sample",
});
var myEvent = new Event
{
Summary = eventName,
Location = location,
Start = new EventDateTime
{
DateTime = startDate,
TimeZone = "Asia/India",
},
End = new EventDateTime
{
DateTime = endDate,
TimeZone = "Asia/India",
},
Recurrence = new String[] { "RRULE:FREQ=WEEKLY;BYDAY=MO" },
//Attendees = new List
//{
//new EventAttendee { Email = "xxxxx#gmail.com"}
//},
};
var recurringEvent = service.Events.Insert(myEvent, "primary");
recurringEvent.SendNotifications = true;
recurringEvent.Execute();
I was trying to create calendar using c# interop.domino.dll function call , the calendar was created successfully but the WHO field is not updated.
static void CreateMeeting(NotesDatabase userDatabase)
{
if (!userDatabase.IsOpen)
{
userDatabase.Open();
}
NotesDocument LNDocument = userDatabase.CreateDocument();
System.DateTime StartDate = new DateTime(2019, 12, 25, 6, 0, 0);
System.DateTime EndDate = new DateTime(2019, 12, 25, 6, 3, 0);
LNDocument.ReplaceItemValue("Form", "Appointment");
LNDocument.ReplaceItemValue("AppointmentType", "Meeting");
LNDocument.ReplaceItemValue("Subject", "Dec 25 - Chirstmas Celebration");
//Set Confidential Level (Public=1 or Private=0)
LNDocument.ReplaceItemValue("$PublicAccess", "1");
//Add Start&End Time of your event
LNDocument.ReplaceItemValue("CALENDARDATETIME", StartDate);
LNDocument.ReplaceItemValue("StartDateTime", StartDate);
LNDocument.ReplaceItemValue("EndDateTime", EndDate);
LNDocument.ReplaceItemValue("StartDate", StartDate);
LNDocument.ReplaceItemValue("Location", "Meeting Hall");
//Add From and To
LNDocument.ReplaceItemValue("Chair", "test/test#test");
LNDocument.ReplaceItemValue("From", "test#DS.test.com");
LNDocument.ReplaceItemValue("Required", "test1/test1");
LNDocument.ReplaceItemValue("EnterSendTo", "test1#DS.test.com");
LNDocument.ReplaceItemValue("SendTo", "test1#DS.test.com");
//Infos in The Body
LNDocument.ReplaceItemValue("Body", "Chirtsmas DAY ...");
LNDocument.ComputeWithForm(true, false);
LNDocument.Save(true, false, false);
}
What is the mistake i am doing with the creation here ?
I have .dotnet core web application. I'm trying to add event by Google Calendar Api but getting error. The error
Google.Apis.Requests.RequestError Forbidden [403] Errors [
Message[Forbidden] Location[ - ] Reason[forbidden] Domain[global] ]
My code is
Event myEvent = new Event
{
Summary = "Appointment",
Location = "Dhaka",
Start = new EventDateTime()
{
DateTime = new DateTime(2018, 9, 17, 10, 0, 0),
TimeZone = "Asia/Dhaka"
},
End = new EventDateTime()
{
DateTime = new DateTime(2018, 9, 17, 10, 30, 0),
TimeZone = "Asia/Dhaka"
},
Recurrence = new String[] {
"RRULE:FREQ=WEEKLY;BYDAY=MO"
},
Attendees = new List<EventAttendee>()
{
new EventAttendee() { Email = "alimcu08#gmail.com" }
}
};
var newEventRequest = calendarService.Events.Insert(myEvent, calendarId);
var eventResult = newEventRequest.Execute();
It's getting error when execute run. By using same calendar service I had got calendar and event list successfully but can't adding event. Any one can help?
Google provided 3 calendars whose have different id. I provided one id from them. That's why event not added. When I replace id by 'primary' it's working fine.
I've got a web application that a user fills out a form and on submit it adds an event to a google calendar. I can insert a single instance of an event onto the calendar but when I try to set the recurrence of the event I am unable to do so. My methods so far have either accomplished nothing or the event is created, but only for a single occurrence.
I am using google api calendar v3 below is my code to insert the event.
try{
Google.Apis.Calendar.v3.CalendarService g = new
Google.Apis.Calendar.v3.CalendarService();
Google.Apis.Calendar.v3.Data.Event ev = new
Google.Apis.Calendar.v3.Data.Event();
//Create Date Times for start and end time
EventDateTime starter = new EventDateTime();
starter.DateTime = start;
EventDateTime ender = new EventDateTime();
ender.DateTime = end;
//Add values to the event
ev.Start = starter;
ev.End = ender;
ev.Summary = summary.Text;
ev.Location = location.Text;
ev.Description = description.Text;
String[] recd = {"RRULE:FREQ=WEEKLY;COUNT=2"};
Random rnd = new Random();
ev.RecurringEventId = "asdf" + rnd.Next(9999).ToString();
ev.Recurrence = recd;
//Add to calendar
addEvent(service, ev);
g.Events.Insert(ev, "********");
}
EDIT 1:
I've rewritten my event creation code as follows:
EventDateTime starter = new EventDateTime();
starter.DateTime = start;
EventDateTime ender = new EventDateTime();
ender.DateTime = end;
Event newEvent = new Event()
{
Summary = summary.Text,
Location = location.Text,
Description = description.Text,
Start = starter,
End = ender,
Recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=2"}
};
String calendarId = "****#group.calendar.google.com";
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
Event createdEvent = request.Execute();
The only problem being that the event will not be created nor its recurrence. If I leave off that line, the code will run and insert the single event into the calendar.
Did you forget to call .execute() ?
Event newEvent = new Event()
{
Summary = "Read Awesome Blog posts by Linda ",
Location = "1600 Amphitheatre Parkway., Mountain View, CA 94043",
Description = "A chance to learn more about Google APIs.",
Start = new EventDateTime()
{
DateTime = DateTime.Parse("2015-09-20T09:00:00-07:00"),
TimeZone = "America/Los_Angeles",
},
End = new EventDateTime()
{
DateTime = DateTime.Parse("2015-09-20T17:00:00-07:00"),
TimeZone = "America/Los_Angeles",
},
Recurrence = new String[] { "RRULE:FREQ=DAILY;COUNT=2" },
Attendees = new EventAttendee[] {
new EventAttendee() { Email = "test#test.com" },
},
Reminders = new Event.RemindersData()
{
UseDefault = false,
Overrides = new EventReminder[] {
new EventReminder() { Method = "email", Minutes = 24 * 60 },
new EventReminder() { Method = "sms", Minutes = 10 },
}
}
};
String calendarId = "primary";
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
Event createdEvent = request.Execute();