Hello jcmag,

You need to set the service.RequestFactory = authFactory on your
CalendarService object before calling Insert (like you did in your
query).  Currently, you're trying to POST a new event without
authenticating, which is the reason for the 401 response.

Hope this helps.

Happy coding,

-Ryan


On Jan 10, 9:23 am, "jcmag" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm using C# 2.0 using the latest SVN code. I can query my calendar
> using this code:
>
> GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("cl",
> "Test-1");
>                 authFactory.Token = userEntity.GoogleCalToken;
>                 CalendarService service = new
> CalendarService(authFactory.ApplicationName);
>                 service.RequestFactory = authFactory;
>                 EventQuery query = new EventQuery();
>                 query.Uri =
>                     new Uri(
>
> string.Format("http://www.google.com/calendar/feeds/{0}/private/full";,
> userEmail));
>                 query.SortOrder = CalendarSortOrder.ascending;
>                 query.FutureEvents = false;
>                 query.SingleEvents = false;
>                 query.NumberToRetrieve = 10;
>                 EventFeed calFeed = service.Query(query);
>
> And it works.
> I can also delete an event, but the insertion fails with a 401 -
> unauthorizedException.
>
>  EventEntry entry = new EventEntry();
>                     AtomPerson author = new
> AtomPerson(AtomPersonType.Author);
>                     author.Name = userName;
>                     author.Email = userEmail;
>                     entry.Authors.Add(author);
>                     entry.Title.Text =
> (string)Session["agendaContent"];
>                     entry.Content.Content = "Meet for a quick lesson.";
>                     When w = new When();
>                     w.StartTime = (DateTime) Session["agendaDate"];
>                     entry.Times.Add(w);
>
>                     Uri postUri = new
> Uri(string.Format("http://www.google.com/calendar/feeds/{0}/private/full";,
> userEmail));
>                     GAuthSubRequestFactory authFactory = new
> GAuthSubRequestFactory("cl", "Test-1");
>                     authFactory.Token = userEntity.GoogleCalToken;
>                     CalendarService service = new
> CalendarService(authFactory.ApplicationName);
>                     service.Insert(postUri, entry);
>
> (The Token (userEntity.GoogleCalToken) is retrieved from my database.)
> 
> What is wrong?


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to