How to export Team Calendars .ics file via REST API in Confluence Data Center

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Purpose

Exporting Team Calendar .ics files via REST API so users can open it in other calendar apps like Google Calendar, Apple Calendar, Microsoft Outlook, or any application that supports importing .ics files. This article is an alternative method to Export Team Calendars Content to Other Calendars

Solution

In this guide, we will cover how to export Team Calendar .ics files via REST API. Please make sure to test this first on a staging instance before attempting it in production. The examples below are for a PostgreSQL database, but can be translated by your DBA to another DBMS type if needed.

  1. Run the query in the Confluence Database. This SQL query will output all calendars that are stored. You will need to get the CALENDAR ID from the below query and locate the calendar you want to export as .ics file.
SELECT 
  tc."ID" as calendar_id, 
  um.lower_username as creator, 
  tc."NAME" as calendar_name, 
  to_timestamp(
    CAST(tc."CREATED" AS bigint)/ 1000
  ) as calendar_creation_date, 
  s.spacekey as space_key, 
  s.spacename 
FROM 
  "AO_950DC3_TC_SUBCALS" tc 
  JOIN user_mapping um ON um.user_key = tc."CREATOR" 
  JOIN spaces s ON s.spacekey = tc."SPACE_KEY" 
WHERE 
  tc."PARENT_ID" IS NULL 
ORDER BY 
  creator;

Which provides output like this::

"calendar_id","creator","calendar_name","calendar_creation_date","space_key","spacename"

"d9a78630-b58a-45ca-9271-317905e814dd","admin","NewCal","2022-12-07 15:35:43+05:30","AN","analytics"
"99a3b91d-515d-46ff-844e-3a61f817c8b3","admin","test","2023-09-08 13:26:35+05:30","DRAG","Dragons" 

2. You can then use the below curl command to export the calendar, so you can open it in other calendar apps like Google Calendar, Apple Calendar, Microsoft Outlook, or any application that supports importing .ics files.

curl --request GET -u <user>:<password> --url <your-base-url>/rest/calendar-services/1.0/calendar/export/subcalendar/<calendar_id>.ics > <calendar_id>.ics

All calendars are stored in AO_950DC3_TC_SUBCALS and a row will be created for each new Event Type used in Calendar.

Each entry will have a unique ID value, but the secondary Event Type entry will have PARENT_ID populated linking back to ID.

All calendars and Event Type calendars can be grouped by NAME column.

You need to change <user>, <password>, <your-base-url>, <calendar_id> accordingly referring to your instance. Your file (<calendar_id>.ics) would get downloaded to the directory you run the curl.

Feature Request

Your feedback and voice are highly appreciated, please feel free to add a comment or engage in the conversation in the suggestion ticket below:

CONFSERVER-51323 - Getting issue details... STATUS


Last modified on Sep 18, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.