Hi Bobb,

I noticed from your copy/paste code from earlier post the way you are
creating the request factory -

    Google.GData.Client.GDataLoggingRequestFactory factory =
      new GDataLoggingRequestFactory("wise", "CalendarLogging");

You are using "wise" as the service name, I think "wise" is the
service name for Google spreadsheet, you should be using "cl" which is
the service name for Google Calendar.  I have a feeling that this
might fix your problem.  Hope this helps :)

Austin

On Wed, Apr 2, 2008 at 4:25 AM, bobb <[EMAIL PROTECTED]> wrote:
>
>  Hi Austin,
>  Your code snippet follows mine almost exactly. I am still getting 401
>  on the batch() call (approx. 25 events at 1 time).
>  However, when I changed the code to do the events 1-by-one with an
>  insert() call instead, it works (removed the trailing "/batch" from
>  the URI)
>
>  Any idea what's going on?
>  bobb
>
>
>
>  On Apr 1, 5:16 pm, "Austin (Google)" <[EMAIL PROTECTED]> wrote:
>  > Hi,
>  >
>  > To insert event using batch, you can take a look at my sample code to
>  > see how this can be done using the .NET client library -
>  >
>  >   public void batchInsert() {
>  >
>  >     // submitting request to your  "default" or your primary calendar
>  >     Uri batchUrl = new Uri("http://www.google.com/calendar/feeds/
>  > default/private/full/batch");
>  >
>  >     // Create an batch entry to insert a new event.
>  >     EventEntry request1 = new EventEntry("Batch Request 1");
>  >     request1.Times.Add(new When(DateTime.Now,
>  > DateTime.Now.AddHours(2)));
>  >
>  >     EventEntry request2 = new EventEntry("Batch Request 2");
>  >     request2.Times.Add(new When(DateTime.Now,
>  > DateTime.Now.AddHours(1)));
>  >
>  >     request1.BatchData = new GDataBatchEntryData("batchrequest1",
>  > GDataBatchOperationType.insert);
>  >     request2.BatchData = new GDataBatchEntryData("batchrequest2",
>  > GDataBatchOperationType.insert);
>  >
>  >     // Add the entries to a new feed.
>  >     AtomFeed batchFeed = new AtomFeed(batchUrl, calendarService);
>  >     batchFeed.Entries.Add(request1);
>  >     batchFeed.Entries.Add(request2);
>  >
>  >     EventFeed batchResultFeed = (EventFeed)
>  > calendarService.Batch(batchFeed, batchUrl);
>  >
>  >     //check the return values of the batch operations to make sure
>  > they all worked.
>  >     //the insert operation should return a 201 and the rest should
>  > return 200
>  >     bool success = true;
>  >     foreach (EventEntry entry in batchResultFeed.Entries)
>  >     {
>  >         if (entry.BatchData.Status.Code != 200 &&
>  > entry.BatchData.Status.Code != 201)
>  >         {
>  >             success = false;
>  >             Console.WriteLine("The batch operation with ID " +
>  >                 entry.BatchData.Id + " failed.");
>  >         }
>  >     }
>  >
>  >     if (success)
>  >     {
>  >         Console.WriteLine("All batch operations successful!");
>  >     }
>  >   }
>  >
>  > Hope that helps,
>  > Austin
>  >
>  > On Mar 21, 6:16 am, bobb <[EMAIL PROTECTED]> wrote:
>  >
>  > > Thanks again, Austin, here are the relevant lines of code (I'm
>  > > omitting all the logic that creates the individual Entry objects)
>  >
>  > >             string feedUri = "http://www.google.com/calendar/feeds/
>  > > default/private/full/batch";
>  > >             System.Uri postUri = new System.Uri(feedUri);
>  > >             CalendarService service = new CalendarService("exampleCo-
>  > > exampleApp-1");
>  > >             AtomFeed CalFeed = new AtomFeed(postUri, service);
>  >
>  > >             service.setUserCredentials(userName, userPassword);
>  >
>  > >             // replace service's logging object with one that logs to
>  > > a file we specify
>  > >             // (for debug only)
>  > >             Google.GData.Client.GDataLoggingRequestFactory factory =
>  > >                 new GDataLoggingRequestFactory("wise",
>  > > "CalendarLogging");
>  > >             factory.MethodOverride = true;
>  > >             factory.CombinedLogFileName = "c:\\temp\\xmllog.log";
>  > >             service.RequestFactory = factory;
>  >
>  > >             for (... loop over input data array....)
>  > >                    {
>  > >                     EventEntry entry = new EventEntry();
>  >
>  > > /* ..... populate the entry instance.... */
>  >
>  > >                     // set the entry to contain an "insert" operation
>  > > directive,
>  > >                     // and add it to the feed object
>  > >                     Int32 I = new Int32();
>  > >                     I = (Int32)index;
>  > >                     entry.BatchData = new
>  > > GDataBatchEntryData(I.ToString(), GDataBatchOperationType.insert);
>  > >                     CalFeed.Entries.Add(entry);
>  > >                     } // end loop
>  >
>  > >                // send it
>  > >               EventFeed results = (EventFeed)service.Batch(CalFeed,
>  > > postUri);          // this is the line that creates the 401 exception
>  >
>  > > On Mar 20, 8:32 pm, "Austin (Google)" <[EMAIL PROTECTED]> wrote:
>  >
>  > > > Hi,
>  >
>  > > > Can you give me a snippet of your code? I will see if I can debug it.
>  >
>  > > > Thanks,
>  > > > Austin
>  >
>  > > > On Thu, Mar 20, 2008 at 5:28 PM, bobb <[EMAIL PROTECTED]> wrote:
>  >
>  > > > > Hi Austin,
>  > > > > Thanks for the correction, but it didn't work. I changed my uri as 
> you
>  > > > > said, but I'm still getting a 401 (Unauthorized) error on the 
> .Batch()
>  > > > > call.
>  > > > > Any other suggestions?
>  > > > > thx
>  >
>  > > > > On Mar 20, 7:12 pm, "Austin (Google)" <[EMAIL PROTECTED]> wrote:
>  > > > > > Hi,
>  >
>  > > > > > The post URL to perform batch request actually requires a "/batch"
>  > > > > appended
>  > > > > > to the end of your regular event feed -
>  >
>  > > > > > so to perform batch request to the primary calendar of your account
>  > > > > would
>  > > > > > use the feed like this -
>  >
>  > > > > >http://www.google.com/calendar/feeds/default/private/full/batch
>  >
>  > > > > > I hope that solved your problem =)
>  >
>  > > > > > For more information on batch protocol, please refer to this doc -
>  >
>  > > > > 
> >http://code.google.com/apis/calendar/developers_guide_protocol.html#b...
>  >
>  > > > > > Hope it helps,
>  > > > > > Austin
>  >
>  > > > > > On Thu, Mar 20, 2008 at 7:48 AM, bobb <[EMAIL PROTECTED]> wrote:
>  >
>  > > > > > > I am uploading calendar entries to the calendar on my company's 
> google
>  > > > > > > page. Originally I was using CalendarService.insert() to upload 
> each
>  > > > > > > entry individually, and it mostly worked.
>  >
>  > > > > > > Now I am converting that code to do a batch upload, for 
> performance
>  > > > > > > reasons, using the exact same uri as before, but now I am getting
>  > > > > > > either a 401 or a 403 exception from the Batch() call, whereas I 
> got
>  > > > > > > no exception from the previous insert() call.
>  >
>  > > > > > > More detail:
>  > > > > > > I create the CalendarService instance and set the user 
> credentials the
>  > > > > > > same way in both cases.
>  > > > > > > The uri in both cases is:
>  > > > > > >    http://www.google.com/calendar/feeds/default/private/full
>  >
>  > > > > > > For the insert() case, I create an EventEntry instance and 
> populate
>  > > > > > > it, then call service.insert with the entry, and it works.
>  >
>  > > > > > > In the Batch() case, I create an AtomFeed, using the same uri, 
> and add
>  > > > > > > a bunch of Entry instances to it.
>  > > > > > > I pass the feed instance and the uri to service.Batch() and get 
> a 401
>  > > > > > > exception.
>  > > > > > > Why would this happen when it worked for insert()?
>  >
>  > > > > > > I tried changing the feed to:
>  > > > > > >    http://www.google.com/calendar/feeds/<[EMAIL 
> PROTECTED]>/public/full
>  >
>  > > > > > > When I did that and used Batch() I got a 403 (Forbidden).
>  >
>  > > > > > > Very puzzling.....
>  >
>

--~--~---------~--~----~------------~-------~--~----~
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