Use Cases for User Absence Planner for Jira API Integration
Overview
The User Absence Planner API for Jira Cloud provides powerful functionality for managing user absences programmatically. This can be leveraged to create seamless integrations with external tools such as Outlook, Google Calendar, or HR systems. Below are some use cases demonstrating how to use these APIs in various scenarios, including no-code solutions using tools like Zapier and custom-developed integrations.
Use Case 1: Integrating with Outlook via Zapier
Objective: Automatically create and update absences in Jira based on events in Outlook Calendar.
Steps:
Create a Zapier Account: Sign up for a free account at Zapier
Set Up a Zap: Create a new Zap in Zapier
Trigger:
Choose “Outlook Calendar” as the trigger app
Select the event trigger, such as “New Event” or “Event Start”
Connect your Outlook account to Zapier and set up the trigger details
Action:
Choose “Webhooks by Zapier” as the action app
Select “POST” for creating a new absence or “PUT” for updating an existing absence
Configure the Webhook:
For creating a new absence:
Set the URL to the createAbsence endpoint (unique for your instance)
Include parameters in URL with the users email address and the cloud site
Define body:
JSON{ "title": "{{Outlook Event Title}}", "type": "Holiday", "start": "{{Outlook Event Start}}", "end": "{{Outlook Event End}}", "message": "Outlook Calendar Event" }
For updating an absence:
Set the URL to the editAbsence endpoint (unique for your instance)
Include parameters in URL with the users email address and the cloud site
Define body:
JSON{ "id": "{{Absence ID}}", "title": "{{Outlook Event Title}}", "type": "Holiday", "start": "{{Outlook Event Start}}", "end": "{{Outlook Event End}}", "message": "Outlook Calendar Event" }
Test and Activate:
Test the Zap to ensure that it correctly creates or updates absences in Jira based on Outlook events
Activate the Zap
Use Case 2: Syncing Absences with Google Calendar
Objective: Automatically create absences in Jira based on events in Google Calendar.
Steps:
Create a Zapier Account: Sign up for a free account at Zapier
Set Up a Zap: Create a new Zap in Zapier
Trigger:
Choose “Google Calendar” as the trigger app.
Select the event trigger, such as “New Event” or “Event Start”.
Connect your Google account to Zapier and set up the trigger details.
Action:
Choose “Webhooks by Zapier” as the action app.
Select “POST” for creating a new absence.
Configure the Webhook:
Set the URL to the createAbsence endpoint (unique for your instance)
Include parameters in URL with the users email address and the cloud site
Define body:
JSON{ "title": "{{Google Calendar Event Title}}", "type": "Holiday", "start": "{{Google Calendar Event Start}}", "end": "{{Google Calendar Event End}}", "message": "Google Calendar Event" }
Test and Activate:
Test the Zap to ensure that it correctly creates absences in Jira based on Google Calendar events
Activate the Zap
Use Case 3: Custom Integration with HR System
Objective: Develop a custom integration to sync employee leave data from an HR system to Jira.
Steps:
Set Up Your Environment:
Choose your programming language (e.g., Python, Node.js)
Set up a development environment and install necessary libraries for making HTTP requests (e.g., requests for Python, axios for Node.js)
Fetch Data from HR System:
Use the API provided by your HR system to fetch employee leave data
Example (Python):
PYimport requests hr_system_url = "https://api.hr-system.com/leaves" response = requests.get(hr_system_url) leaves = response.json()
Map Data to Jira API:
Map the leave data from the HR system to the fields required by the User Absence Planner API
Example (Python):
PYfor leave in leaves: data = { "title": leave["title"], "type": leave["type"], "start": leave["start_date"], "end": leave["end_date"], "message": leave["notes"] }
Send Data to Jira API:
Use the createAbsence endpoint to create absences in Jira
Example (Python):
PYjira_url = "<cloud_site_unique_createAbsence_endpoint>?user=<user_email_address&cloudSite=<your_cloud_site>" headers = {"Content-Type": "application/json"} for leave in leaves: data = { "title": leave["title"], "type": leave["type"], "start": leave["start_date"], "end": leave["end_date"], "message": leave["notes"] } response = requests.post(jira_url, json=data, headers=headers) if response.status_code == 201: print(f"Successfully created absence for {leave['email']}") else: print(f"Failed to create absence for {leave['email']}: {response.text}")
Conclusion
These use cases demonstrate how the User Absence Planner API can be integrated with external tools and systems. By using no-code solutions like Zapier or developing custom integrations, you can automate the management of user absences and ensure seamless synchronisation across different platforms.