Calendar Library Event Reminders

I am trying to override event reminders. The setting in the event reminder structure ‘UseDefaut : false’ seems to have no effect. Sending the event reminder structure with just the overrides results in the following error

{“conferenceData”:{“createRequest”:{“conferenceSolutionKey”:{“type”:“hangoutsMeet”},“requestId”:“rrrr”}},“description”:“Link to create notes, Link to book next appointment. Instructions HTML Formatted”,“end”:{“dateTime”:“2018-11-01T21:00:00-04:00”,“timeZone”:“America/Toronto”},“reminders”:{“overrides”:[{“method”:“email”,“minutes”:120},{“method”:“email”,“minutes”:90},{“method”:“popup”,“minutes”:30}]},“start”:{“dateTime”:“2018-11-01T20:00:00-04:00”,“timeZone”:“America/Toronto”},“summary”:“Client Name Type of Service”}2018/10/31 08:14:27 The err googleapi: Error 400: Cannot specify both default reminders and overrides at the same time., cannotUseDefaultRemindersAndSpecifyOverride

I know this has something to do with the googleapi,MarshalJSON and setting ForceSendFields but nothing seems to work. Using the API explorer it is straight forward and works properly.

1 Like

I realise my initial post was woefully inadequate and I apologise. Hopefully this followup will clarify.

I am using go version go1.11 linux/amd64 and the latest version of the Calendar API https://godoc.org/google.golang.org/api)/[calendar](https://godoc.org/google.golang.org/api/calendar/v3

I am trying to create an event that contains remainders as illustrated below and this code produces:
2018/10/31 08:14:27 The err googleapi: Error 400: Cannot specify both default reminders and overrides at
the same time., cannotUseDefaultRemindersAndSpecifyOverride

I have tried adding the UserDefault = false and setting the newEvent.ForceSendFields = []string{“UseDefault”} to no avail.

If I completely remove the remainders section the the call is successful and picks up the calendar default notifications even if I include the reminders UseDefault= false.

Using the API Explorer with the raw api works as expected so I am led to believe there is something wrong in the library.

You assistance is appreciated.

Thanks

newEvent := &calendar.Event{
  ConferenceData: &calendar.ConferenceData{
	CreateRequest: &calendar.CreateConferenceRequest{
		ConferenceSolutionKey: &calendar.ConferenceSolutionKey{
			Type: "hangoutsMeet",
		},
		RequestId: "1234",
	},
  },
 Reminders: &calendar.EventReminders{
	Overrides: []*calendar.EventReminder{
		&calendar.EventReminder{
			Method:  "email",
			Minutes: 120,
		},
		&calendar.EventReminder{
			Method:  "email",
			Minutes: 90,
		},
		&calendar.EventReminder{
			Method:  "popup",
			Minutes: 30,
		},
	},
  },
}
newEvent.Summary = "Client Name Type of Service"
newEvent.Description = "Link to create notes, Link to book next appointment. Instructions HTML Formatted"
var dt [2]calendar.EventDateTime
dt[0].TimeZone = theSlot.TimeZone
dt[1].TimeZone = theSlot.TimeZone
dt[0].DateTime = theSlot.StartTime.Format("2006-01-02T15:04:05-07:00")
newEvent.Start = &dt[0]
dt[1].DateTime = theSlot.EndTime.Format("2006-01-02T15:04:05-07:00")
newEvent.End = &dt[1]
_, err := 
  srv.Events.Insert("hasubehaviouralhealth.ca_mcbpge4nm5s8ddgsvn4o99atoc@group.calendar.google.com", 
         newEvent).ConferenceDataVersion(1).Do()
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/john/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/john/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build319526860=/tmp/go-build -gno-record-gcc-switches"
1 Like

Eureka!!! Nothing wrong in the library
The problem was, as usual; the user ::

newEvent.ForceSendFields = []string{“UseDefault”} 

Should have been

newEvent.Reminders.ForceSendFields = []string{"UseDefault"}

Using the ForceSend is not something I use every day (2nd time since I started with GO <6 months ago>) and it is resident on most library structures so be careful.

Hope this helps someone

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.