Update holidays of all JSM project's calendars via Rest API
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
At times, we need to add holidays in all project's calendar and we can leverage Rest API to achieve this.
Solution
Create an API token for your Atlassian account by following the steps in "Manage API tokens" for your Atlassian account. Ensure that you securely store the API token.
Open Postman and create a new request. In the Authorization tab, enter the API token as the authentication method.
Send a GET request to the following URL to retrieve a list of all calendars:
GET https://<SiteURL>/rest/workinghours/1/api/calendar
Find the ID of the calendar you want to update from the list obtained in the previous step.
Send another GET request to fetch the details of the specific calendar using its ID. For example:
GET https://<SiteURL>/rest/workinghours/1/api/calendar/<id>
Review the JSON response to understand the current calendar details, including holidays and working times.
Update the "holidays" section in the JSON response to modify the calendar data. For example, if you want to change the date of "Holiday 1" to 21st July 2023, make the necessary adjustments.
Remove the "canUpdate," "canDelete," "deletable," and "updateMessage" sections from the JSON to get a clean JSON representation of the calendar data.
Send a PUT request to update the calendar with the modified JSON data. Use the same URL as the GET request, but this time, use the updated JSON data in the "body" tab of the request.
Once the PUT request is sent successfully, the calendar will be updated in Jira. Repeat these steps for any other calendars you want to update.