A local VS2015 ASP.NET 4.5 application throws this exception when I attempt to request events from my Google Calendar:
Google.GoogleApiException was unhandled by user code
HResult=-2146233088 Message=Google.Apis.Requests.RequestError Not Found [404] Errors [ Message[Not Found] Location[ - ] Reason[notFound] Domain[global] ]
My application accesses primary
calendar events without throwing a fuss, but takes issue when I attempt to specify a specific calID
. Is there a relatively straightforward remedy for this error?
I was careful to follow advice from other posts like Google Calendar API v3 Access Not Configured about removing the @group.calendar.google.com
extension from my Calendar ID under the settings menu. I used OAuth, a Client ID for a native application, and enabled my localhost
as a redirect URI.
UserCredential credential;
using (var stream =
new FileStream(@"c:\Authentication\my_client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
// Create Google Calendar API service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request
string calID = "{MY_SECRET_CAL_ID}";
EventsResource.ListRequest request = service.Events.List(calID.ToString());
request.TimeMin = DateTime.Now;
request.ShowDeleted = false;
request.SingleEvents = true;
request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
// List events.
Events events = request.Execute();
Stack Trace:
ServiceName=calendar Source=Google.Apis StackTrace: at Google.Apis.Requests.ClientServiceRequest`1.Execute() in c:\code\github\google-api-dotnet-client\Tools\Google.Apis.Release\bin\Release\1.9.2\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:line 93 at ConferenceTracker.North.LoadCalendar() in C:\Users\MYUSER\Desktop\NewConferenceTracker\ConferenceTracker\ConferenceTracker\North.aspx.cs:line 132 at ConferenceTracker.North.RunStartupRoutine() in C:\Users\MYUSER\Desktop\NewConferenceTracker\ConferenceTracker\ConferenceTracker\North.aspx.cs:line 94 at ConferenceTracker.North.Page_Load(Object sender, EventArgs e) in C:\Users\MYUSER\Desktop\NewConferenceTracker\ConferenceTracker\ConferenceTracker\North.aspx.cs:line 64 at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: