A valid atom entry has to have an author and a few more things for retrieval, for publishing it needs at least an author and title text (hope i am not forgetting anything).
So add an author to the entry, and you should be fine. Below you find my standard test atom object, that i create for test cases:
public static AtomEntry CreateEventEntry(int iCount)
{
EventEntry entry = new EventEntry();
// some unicode chars
Char[] chars = new Char[] {
'\u0023', // #
'\u0025', // %
'\u03a0', // Pi
'\u03a3', // Sigma
'\u03d1', // beta
};
// if unicode needs to be disabled for testing, just uncomment this line
// chars = new Char[] { 'a', 'b', 'c', 'd', 'e'};
AtomPerson author = new AtomPerson(AtomPersonType.Author);
author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3];
author.Email = "[EMAIL PROTECTED]";
entry.Authors.Add(author);
AtomCategory cat = new AtomCategory();
cat.Label = "Default";
cat.Term = "Default" + chars[4] + " Term";
entry.Categories.Add(cat);
entry.Content.Content = "this is the default text entry";
entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);
entry.Title.Text = "This is a entry number: " + iCount;
entry.Updated = DateTime.Now;
When newTime = new When();
newTime.StartTime = DateTime.Today;
newTime.EndTime = DateTime.Today.AddDays(1);
entry.Times.Add(newTime);
Who someone = new Who();
someone.ValueString = "[EMAIL PROTECTED]";
Who.AttendeeStatus status = new Who.AttendeeStatus();
status.Value = "event.accepted";
someone.Attendee_Status = status;
someone.Rel = "http://schemas.google.com/g/2005#event.organizer";
entry.Participants.Add(someone);
Where newPlace = new Where();
newPlace.ValueString = "A really nice place";
entry.Locations.Add(newPlace);
return entry;
}
/////////////////////////////////////////////////////////////////////////////
Frank Mantek
On 6/8/06, br_shine <
[EMAIL PROTECTED]> wrote:
Hi all, i'm trying to create a new event trow a custom application
using the Calendar API for c#. I can access the calendar events, but
when I try to create a new event I get a GDataRequestException (The
remote server returned an error: (500) Internal Server Error.). This is
the code i'm using:
Appointment app = o as Appointment;
FeedQuery query = new FeedQuery();
CalendarService service = new CalendarService("myCalendar");
service.setUserCredentials(usrSet.Name, usrSet.Password);
GDataGAuthRequestFactory factory = (GDataGAuthRequestFactory)
service.RequestFactory;
// temporary measure
factory.MethodOverride = true;
EventEntry ev = new EventEntry();
ev.Title.Text = app.Subject;
When time = new When();
time.StartTime = app.Start;
time.EndTime = app.End;
ev.Times.Add(time);
try
{
AtomEntry insertedEntry = service.Insert(usrSet.RemoteUri,ev);
}
catch (GDataRequestException e1)
{
Console.Write(e1.Response);
}
Can anyone tell me what am i doing wrong?
Thanks
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
- Re: c# > GDataRequestException when trying to create a new... Frank Mantek
