简体   繁体   中英

C# Google calendar api service.Events.Insert invalid Domain global

When I try to call service.Events.Insert( myEvent, "primary" ) I get the following error:

The service calendar has thrown an exception: Google.GoogleApiException: Google.Apis.Requests.RequestError
Invalid Value [400]
Errors [
    Message[Invalid Value] Location[ - ] Reason[invalid] Domain[global]
]

myEvent contains these value:

Event myEvent = new Event
{
 Summary = summary,
 Description = description,
 Location = location,
 Id = id,
 Start = new EventDateTime( )
 {
  DateTime = startPoint,
  TimeZone = timeZoneName
 },
 End = new EventDateTime( )
 {
  DateTime = endPoint,
  TimeZone = timeZoneName
 }
};

What does this error mean?

Is there in Google a place to look why a particular exception was thrown?

I've searched my files and I don't specify GLOBAL anywhere.

The error 400: Bad Request or user error. This mean that a required field or parameter has not been provided, the value supplied is invalid, or the combination of provided fields is invalid. So make sure to provide the valid value for the methods. Here is a code example on how to properly set the values.

Event newEvent = new Event()
{
    Summary = "Google I/O 2015",
    Location = "800 Howard St., San Francisco, CA 94103",
    Description = "A chance to hear more about Google's developer products.",
    Start = new EventDateTime()
    {
        DateTime = DateTime.Parse("2015-05-28T09:00:00-07:00"),
        TimeZone = "America/Los_Angeles",
    },
    End = new EventDateTime()
    {
        DateTime = DateTime.Parse("2015-05-28T17:00:00-07:00"),
        TimeZone = "America/Los_Angeles",
    },

One more thing make sure your date format should be “yyyy-mm-dd”. It is based on this page

Also if using Recurrence in the calendar entry, and specifying the 'Until' rule check it has a "z" at the end of the string.

UNTIL=20180117T235959Z 

and not

UNTIL=20180117T235959 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM