最新の Google Data API SDK を使用して Google カレンダーを更新しようとしています。
以下の私のサンプルコード:
string sGoogleUserName = "xxxx@gmail.com";
string sGooglePassword = "xxxxxxxx";
Uri oCalendarUri = new Uri("http://www.google.com/calendar/feeds/" +
sGoogleUserName + "/private/full");
//Initialize Calendar Service
CalendarService oCalendarService = new CalendarService("CalendarSampleApp");
oCalendarService.setUserCredentials(sGoogleUserName, sGooglePassword);
//Use Proxy
GDataRequestFactory oRequestFactory =
(GDataRequestFactory)oCalendarService.RequestFactory;
WebProxy oWebProxy = new WebProxy(
WebRequest.DefaultWebProxy.GetProxy(oCalendarUri));
oWebProxy.Credentials = CredentialCache.DefaultCredentials;
oWebProxy.UseDefaultCredentials = true;
oRequestFactory.Proxy = oWebProxy;
//Set Event Entry
EventEntry oEventEntry = new EventEntry();
oEventEntry.Title.Text = "Test Calendar Entry From .Net";
oEventEntry.Content.Content =
"Hurrah!!! I posted my first Google calendar event through .Net";
//Set Event Location
Where oEventLocation = new Where();
oEventLocation.ValueString = "New Zealand";
oEventEntry.Locations.Add(oEventLocation);
//Set Event Time
When oEventTime = new When(new DateTime(2011, 5, 31, 9, 0, 0),
new DateTime(2011, 5, 31, 9, 0, 0).AddHours(1));
oEventEntry.Times.Add(oEventTime);
//Set Additional Properties
ExtendedProperty oExtendedProperty = new ExtendedProperty();
oExtendedProperty.Name = "SynchronizationID";
oExtendedProperty.Value = Guid.NewGuid().ToString();
oEventEntry.ExtensionElements.Add(oExtendedProperty);
// CalendarService oCalendarService = GAuthenticate();
//Prevents This Error
//{"The remote server returned an error: (417) Expectation failed."}
System.Net.ServicePointManager.Expect100Continue = false;
//Save Event
oCalendarService.Insert(oCalendarUri, oEventEntry);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
これが以下のエラーです
Google.GData.Client.GDataRequestException: 認証要求の実行が予期しない結果を返しました: Google.GData.Client.Utilities.getAuthException(TokenCollection tokens, HttpWebResponse response) で 405 Google.GData.Client.Utilities.QueryClientLoginToken(GDataCredentials gc, String serviceName 、文字列 applicationName、ブール値 fUseKeepAlive、IWebProxy proxyServer、Uri clientLoginHandler) で Google.GData.Client.GDataGAuthRequest.QueryAuthToken(GDataCredentials gc) で Google.GData.Client.GDataGAuthRequest.EnsureCredentials() で Google.GData.Client.GDataRequest.EnsureWebRequest( ) で Google.GData.Client.GDataGAuthRequest.EnsureWebRequest() で Google.GData.Client.GDataGAuthRequest.CopyRequestData() で Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter) で Google.GData.Client.GDataGAuthRequest で。Execute() at Google.GData.Client.Service.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data) at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data) at Google.GData .Client.Service.Insert[TEntry](Uri feedUri, TEntry エントリ)