Hello,
I am currently building an appointment finder in asp.net core. I managed to get a code 200 when accessing the calendar.
However, the event I want to send is not saved by Google Calendar. The console dashboard shows it's received. There is only one calendar in the account.
My code so far:
public void InsertIntoCalendar()
{
var Cal = new CalendarEvents();
var newEvent = Cal.CreateEvent("TestEvent", "RandomLocation", "Description", "2017-07-28");
var service = CreateService();
service.Events.Insert(newEvent, serviceAccountEmail).Execute();
String calendarId = "primary";
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
Event createdEvent = request.Execute();
}
CalendarEvents is a class that's creating an Event by several methods. I tried using the Event class itself, but the outcome is the same.
The Service is created like this:
private CalendarService CreateService()
{
string keyFilePath = "random.p12;
var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = Scopes
}.FromCertificate(certificate));
// Create the service.
CalendarService service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
//ApplicationName = "ShowCase",
});
return service;
}
On the cshtml page, I do this with razor:
CalendarConnection TestConnection = new CalendarConnection();
TestConnection.InsertIntoCalendar();
I am getting a code 200, but the event is not insterted into the calendar. I read the perl article about this, but I cannot make anything out of it.
What am I doing wrong?
Thank you in advance.
Edit: When I call events.list from a console application, I can see the events:
TEST (26.07.2017 20:58:08)
TEST (26.07.2017 20:58:57)
TEST (26.07.2017 21:03:38)
TEST (26.07.2017 21:05:27)
Why don't I see them in the calendar?