Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,461,683
Community Members
 
Community Events
176
Community Groups

Confluence REST API to read Calendar events

I didn't find any official REST API to read calendar events but got to know about an unofficial end point to get event data in one of the discussion thread.

https://stackoverflow.com/questions/44412554/calendar-info-using-confluence-api

https://community.atlassian.com/t5/Answers-Developer-Questions/Team-Calendar-list-events-API/qaq-p/532723

 

End point - https://yourconfluence.com/rest/calendar-services/1.0/calendar/events.json?subCalendarId=40xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&userTimeZoneId=US%2FPacific&start=2019-01-28T00%3A00%3A00Z&end=2019-06-28T00%3A00%3A00Z

 

Curl response I'm getting is {"success":true} but it doesn't have any event list. I did verified date ranges again and again and we have events within input date range.

 

So, is there something I'm doing wrong here? Any pointers? Thanks.

 

4 answers

2 accepted

3 votes
Answer accepted

Hey, just letting you (and anyone who stumbles across this post, like I did) know, the unofficial API is currently working.

I got the same problem as you, and eventually figured out that the cause was the structure of the calendar itself. It appears that Team Calendars stores each calendar as multiple sub-calendars, with each sub-calendar managing a different type of event (e.g. Leave, Travel, etc).

So it's returning success=true because technically that call is doing what it's supposed to: it's just there are no events associated with the derived calendar - which is likely to be the ID you're using - they're all in the sub-calendars.

The way I found to get it working was by using the ID's of the sub-calendars instead. The easiest way I found to figure those out is to go into the network calls. There you should find some number of calls (that correspond to the number of event types of events in that time range) that start like events.json?subCalendarId=<some numbers>. You can copy the URL's of those calls, and they'll give you the sub-calendar ID's and the different API calls you need to make. 

Good luck!

I was having the same challenge and found rest/calendar-services/1.0/calendar/subcalendars.json? returns all the calenders I am subscribed to parents and all. I then went through the list to get the subcalender IDs and get the events for each sub calender.

Like Tiago Tex Pine likes this
3 votes
Answer accepted

Hello Vaibhav and welcome to the Community!

The REST API endpoint you’re using may be responding, but it doesn’t seem to be fully developed as of now. There is a feature request for Confluence Server to have this added under support. You may find that feature request at CONFSERVER-51323. We would suggest you vote and watch this request to receive future updates.

As of now, there is not an available REST API endpoint which will give you access to the calendar events.

Regards,
Stephen Sifers

Thanks Stephen for your response. I will vote for feature request.

Like # people like this

This snippet may help as I experienced the same issue.

Looking at the URL you posted the arguments seem to be missing this argument _ , which appears to be a timestamp/epoch. Once I added this value I received events and not just

{"success":true} 

Take a look at this Laravel/PHP code snippet that works for me


$response
= Http::withToken(config('confluence.api.token'))
->get(sprintf('https://%s/rest/calendar-services/1.0/calendar/events.json',
config('confluence.api.hostname')),
[
'subCalendarId' => config('confluence.calendar.sub_calendar_id'),
'userTimeZoneId' => 'Australia/Sydney',
'start' => $this->argument('start'),
'end' => $this->argument('end'),
'_' => now()->timestamp,
]);

 The now()->timestamp is essentially the same as this bash command

date "+%s"
1614030878

 Hope that helps

They must have not liked this hole.  Even with the
_
 param it returns
{"success":true}

Any other ideas?  I found the events and even the js files that parse the subcalendars .  There is just way too much code there for me to bother with.

Has anyone figured out a good page scrape using regex or found another way to locate the list of sub-calendars (or how to request them)?

Thanks!

Update:

Use headless chromium, deno or Node.js to grab the page with all of the dynamic parts and then parse out the information on the events.  Then using that information you can pull the data without any problems. 

The Simple Solution (But not exactly REST) is to use the iCal export (the subscribe button).  Then use an iCal library to parse the data. 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events