User Absence Planner Cloud Documentation
Auto Light Dark
Auto Light Dark

Custom Integration with HR System

Objective: Develop a custom integration to sync employee leave data from an HR system to Jira.

Steps:

  1. Set Up Your Environment:

    1. Choose your programming language (e.g., Python, Node.js)

    2. Set up a development environment and install necessary libraries for making HTTP requests (e.g., requests for Python, axios for Node.js)

  2. Fetch Data from HR System:

    1. Use the API provided by your HR system to fetch employee leave data

    2. Example (Python):

      Python
      import requests
      
      hr_system_url = "https://api.hr-system.com/leaves"
      response = requests.get(hr_system_url)
      leaves = response.json()
      
  3. Map Data to Jira API:

    1. Map the leave data from the HR system to the fields required by the User Absence Planner API

    2. Example (Python):

      Python
      for leave in leaves:
          data = {
              "title": leave["title"],
              "type": leave["type"],
              "start": leave["start_date"],
              "end": leave["end_date"],
              "message": leave["notes"]
          }
      
  4. Send Data to Jira API:

    1. Use the createAbsence endpoint to create absences in Jira

    2. Example (Python):

      Python
      jira_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}")