0

I need to create a event in a public calendar wit asp.net I search a lot of examples but none of them helped with my question. Please look at the following code, he has no errors but don't add the event to google calendar. Any help will be appreciated.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Google.Apis.Calendar;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Calendar.v3;
using Google.Apis.Services;

public partial class google : System.Web.UI.Page
{

    private object ddlCalendars;

    public IClientService Calendar_Service { get; private set; }

    protected void Page_Load(object sender, EventArgs e)
    {

        Event evnt = new Event();
        evnt.Summary = "Evento criado por programa";

        evnt.Location = "Coimbra";
        evnt.Description = "Este evento foi criado por programa";

        EventDateTime startTime = new EventDateTime() { DateTime = DateTime.ParseExact("05/04/2017 10:00:00", "dd/MM/yyyy HH:mm:ss", null) };// new EventDateTime();       
        EventDateTime endTime = new EventDateTime() { DateTime = DateTime.ParseExact("05/04/2017 11:00:00", "dd/MM/yyyy HH:mm:ss", null) }; // new EventDateTime();
        evnt.Start = startTime;
        evnt.End = endTime;

        EventAttendee ea = new EventAttendee();
        ea.DisplayName = "Mario";
        ea.Email = "myemail";
        ea.Organizer = false;
        ea.Resource = false;

        IList<EventAttendee> lstOfAtendee = new List<EventAttendee>();
        lstOfAtendee.Add(ea);
        evnt.Attendees = lstOfAtendee;

        EventsResource er = new EventsResource(Calendar_Service);
        er.Insert(evnt, ea.ToString());  

    }
}
AL.
  • 36,815
  • 10
  • 142
  • 281
mariolopes
  • 13
  • 1
  • 7
  • I've taken a look around, but haven't found any `EventsResource.Insert` function. Did you perhaps meant to use [`EventsResource.InsertRequest`](https://developers.google.com/resources/api-libraries/documentation/calendar/v3/csharp/latest/classGoogle_1_1Apis_1_1Calendar_1_1v3_1_1EventsResource.html#a81956b21506c97071b61918bb55cdb78), like what is shown in this [post](http://stackoverflow.com/q/35907624/4625829)? – AL. Apr 06 '17 at 04:01
  • Can you step through it in the debugger and inspect variable values? Are you sure you want to create an event _every time the page loads_? – Nick.Mc Apr 06 '17 at 04:05
  • HI AL. I now the post you mention in your comment but I have one error "Object not contain a definition for events..." Nick It's a test file, I don't need to create one event every time the page loads but I want to show the includes with the least code possible, mabe the problem is here. – mariolopes Apr 07 '17 at 09:17

0 Answers0