Everything else is working fine.
I can Authorize, get calendars, get events and Quick add an event on any calendar. But for some reason I am getting an error when I try to create an event using:
Event request = service.Events.Insert(testEvent, calendarID).Fetch();
I am using VS2010 .Net 4.0 and c:\googlecode\11-23-2011\
I get the same errors no matter which calendar or google account I use.
Any thoughts on what might be wrong?
Thanks,
Dan B
Here is the code:
Event testEvent = new Event();
DateTime startDate=DateTime.Now.AddMinutes(30);
testEvent.Description = "This is a test event generated by me";
testEvent.Start = new EventDateTime();
testEvent.Start.DateTime =startDate.ToString();
testEvent.End = new EventDateTime();
testEvent.End.DateTime = startDate.AddMinutes(30).ToString();
testEvent.Summary = "Test Event";
EventReminder reminder = new EventReminder();
reminder.Method = "popup";
reminder.Minutes = 30;
testEvent.Reminders = new Event.RemindersData();
testEvent.Reminders.Overrides = new List<EventReminder>();
testEvent.Reminders.Overrides.Add(reminder);
testEvent.Reminders.UseDefault = false;
testEvent.Visibility = "public";
testEvent.Attendees = new List<EventAttendee>();
EventAttendee ea = new EventAttendee();
ea.DisplayName="Dan B";
ea.Organizer=true;
testEvent.Attendees.Add(ea);
var service = new CalendarService(auth);
Event request = service.Events.Insert(testEvent, calendarID).Fetch();
Here is the URL it is requesting
{Google.Apis.Requests.Request(insert @
https://www.googleapis.com/calendar/v3/calendars/calendarID/events?alt=json&prettyPrint=true)}
Here is the Stack Trace:
Google.GoogleApiRequestException was unhandled
Message=Google.Apis.Requests.RequestError
Bad Request [400]
Errors [
Message[Bad Request] Location[ - ] Reason[badRequest] Domain[global]
]
Source=Google.Apis
StackTrace:
at Google.Apis.Requests.Request.AsyncRequestResult.GetResponse() in c:\googlecode\11-23-2011\default\Src\GoogleApis\Apis\Requests\Request.cs:line 300
at Google.Apis.Requests.ServiceRequest`1.GetResponse() in c:\googlecode\11-23-2011\default\Src\GoogleApis\Apis\Requests\ServiceRequest.cs:line 183
at Google.Apis.Requests.ServiceRequest`1.Fetch() in c:\googlecode\11-23-2011\default\Src\GoogleApis\Apis\Requests\ServiceRequest.cs:line 203
at GoogleCalStuff.AuthForm.btnCreateEvent_Click(Object sender, EventArgs e) in C:\DEV\GoogleCalStuff\GoogleCalStuff\AuthForm.cs:line 272
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at GoogleCalStuff.Program.Main() in C:\DEV\GoogleCalStuff\GoogleCalStuff\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Net.WebException
Message=The remote server returned an error: (400) Bad Request.
Source=System
StackTrace:
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Google.Apis.Requests.Request.InternalEndExecuteRequest(IAsyncResult asyncResult) in c:\googlecode\11-23-2011\default\Src\GoogleApis\Apis\Requests\Request.cs:line 326
InnerException: