asifshaon / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

API Create new Calendar Event Failed #186

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Calendar API, other functions work fine. But I get an Exception while Create 
a New Event:

the Code is

            var e = new Event
                        {
                            Summary = "Appointment",
                            Location = "Starbuck in PP2",
                            Description = "Dummy Description",
                            Start = new EventDateTime
                                        {
                                            Date = "2012-02-14",
                                            DateTime = "2012-02-14T08:00:00.000:+08:00",
                                            TimeZone = "Hong Kong"
                                        },
                            End = new EventDateTime
                                      {
                                          Date = "2012-02-14",
                                          TimeZone = "Hong Kong",
                                          DateTime = "2012-02-14T08:30:00.000:+08:00"
                                      },

                        };
            var request = service.Events.Insert(e, "primary");
            request.SendNotifications = true;
            var createdEvent = request.Fetch();

The Exception is:

Google.Apis.Requests.RequestError
Bad Request [400]
Errors [
    Message[Bad Request] Location[ - ] Reason[badRequest] Domain[global]
]

Original issue reported on code.google.com by MinQin83 on 15 Feb 2012 at 5:44

GoogleCodeExporter commented 9 years ago
if your .Net example of Creating event, the code is :

      Start = new EventDateTime() { DateTime = new DateTime("2011-06-03T10:00:00.000:-07:00") },
      End = new EventDateTime() { DateTime = new DateTime("2011-06-03T10:25:00.000:-07:00") },

while it should be 

      Start = new EventDateTime() { DateTime = "2011-06-03T10:00:00.000-07:00" },
                                                                      ~~~
      End = new EventDateTime() { DateTime = "2011-06-03T10:25:00.000-07:00" },
                                                                     ~~~

there should not be  ":" before the time zone!

Original comment by MinQin83 on 15 Feb 2012 at 6:14

GoogleCodeExporter commented 9 years ago

Original comment by asky...@google.com on 25 Apr 2012 at 7:13

GoogleCodeExporter commented 9 years ago
I had a similar problem. Solved with this hint. Thx
1) It would be great if there would be a meaningful error message
2) It would be best if the .net api would abstract this detail by using a 
DateTime value which is then converted in whatever format is needed.

Original comment by christop...@gmail.com on 15 Oct 2012 at 10:20

GoogleCodeExporter commented 9 years ago
I believe that Date can be added only when it is an all-day event, otherwise 
one must use DateTime to set it if it has a start and an end.

For reference check this, 
https://developers.google.com/google-apps/calendar/v3/reference/events/insert

Original comment by chunkyr...@gmail.com on 25 Dec 2012 at 9:28