1

I'm able to create an event using insert, but I would like to get the link I can give to my users so this screen appears:

enter image description here

The link looks like this: https://calendar.google.com/event?action=TEMPLATE&tmeid=Mm4zaXFnZHEyZHRwMG1qOTRtdW1idW5wanMgbFjaG9jYWJAbQ&tmsrc=myemail@gmail.com

In the GUI this is called "Publish Event"

enter image description here

enter image description here

enter image description here

How can I do this using the API?

nachocab
  • 13,328
  • 21
  • 91
  • 149

1 Answers1

2

How about this answer?

I think that the link might not be able to be directly retrieved by the Calendar API. But, I think that the structure of link can be created using the calendar ID and htmlLink of the event retrieved by the methods of "Events: get" and "Events: list" in Calendar API. In this answer, I would like to propose the method for this. The flow of this method is as follows.

Flow:

  1. Retrieve the calendar ID.

    • In your case, it's tmsrc=myemail@gmail.com.
  2. Retrieve the event ID.

    • In this case, you can retrieve this using the methods of "Events: list" in Calendar API like below.

        curl \
          'https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events?timeMax=###&timeMin=###' \
          --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
          --header 'Accept: application/json' \
          --compressed
      
  3. Retrieve htmlLink using the method of "Events: get" in Calendar API. Please use the retrieved event ID here.

     curl \
       'https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}' \
       --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
       --header 'Accept: application/json' \
       --compressed
    
    • htmlLink is like https://www.google.com/calendar/event?eid=###. ### is the base65 encoded event ID and calendar ID. Ref So also, you can create this. This is used for the next section.
  4. Create the link you want.

    • The link is like https://calendar.google.com/event?action=TEMPLATE&tmeid=###&tmsrc={calendarId}
    • ### of the value of eid can be retrieved from the retrieved htmlLink.

References:

I think that as a test, you can retrieve the values using "Try this API" of the following pages.

Tanaike
  • 181,128
  • 11
  • 97
  • 165