Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

C# Google Calendar API - not valid Deadline calendar format

When I want to execute the event, it doesn't execute (which means that the event is not in my calendar), and I get the following error:

System.FormatException: The "Deadline calendar" google-api-dotnet-client/1.42.0.0 (gzip) value format is not valid.

Any idea how to fix this? It worked some month ago and I just noticed that it doesn't work anymore.

Some code example:

public static CalendarService getCalendarService
{
   get
   {
      var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret },
      new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None).Result;
         return new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "Deadline calendar" });
    }
};

var ev = new Event
{
   ICalUID = project.RefId,
   Description = project.Description,
   Summary = string.Format("'{0} ({1})' project deadline", project.Name, project.RefId),
   Location = project.Location,
   Start = new EventDateTime { TimeZone = "MST", DateTime = project.EndDate.Value.Date },
   End = new EventDateTime { TimeZone = "MST", DateTime = project.EndDate.Value.Date.AddDays(1) },
   Attendees = attendees.Select(x => new EventAttendee() { Email = x.Email, Organizer = (x.Id == project.Responsible ? true : false) }).ToList()
};

var projectEvent = getCalendarService.Events.Insert(ev, "primary");
projectEvent.SendNotifications = true;
projectEvent.Execute();


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Well, the problem was the format of the application name. I used characters which aren't allowed in this string, like: "á, ?".

Thanks your anwers anyway! :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...