Unable to insert calendar to service accout CalendarList

52 views
Skip to first unread message

Eduardo Gameiro

unread,
Nov 4, 2023, 10:50:15 AM11/4/23
to Google Calendar API
I'm trying to include a new calendar in my service account calendarList. 
I did the authentication process using my Service Account credentials.

Here is the code I'm using :

Dim serviceEmail As String = "xxxxx...@yyyyyyyyyyyyy-agenda.iam.gserviceaccount.com"
    Dim keyPah As String = Server.MapPath("/Chave/client_secret.json")
    Dim Path2 As String = Server.MapPath("/Chave/ffffffffffffffffffffffff-53d3bf16eb43.p12")
    Dim service2 As CalendarService
    Dim calendarId As String = "mye...@gmail.com"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        service2 = AuthenticateServiceAccount(serviceEmail, keyPah, Path2)

        ' Create a new CalendarListEntry to insert into the user's calendar list
        Dim calendarListEntry As New CalendarListEntry()
        calendarListEntry.Id = calendarId

        ' Insert the calendar into the user's calendar list
        Dim request1 As CalendarListResource.InsertRequest = service2.CalendarList.Insert(calendarListEntry)
        request1.Execute()

When I run it I got the error  "Google.GoogleApiException: 'The service calendar has thrown an exception. HttpStatusCode is NotFound. Not Found'"

I'm sure that myemail exist because it is the email that I normally use.

Can someone point me what I doing wrong...
Thank you.

Reply all
Reply to author
Forward
0 new messages