How to use confluence attachments in Jira Automation

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

   

This custom solution utilizes an internal API endpoint, which is subject to alterations without prior notification, potentially leading to the disruption of the implemented solution. 

Summary

This article explains how to send direct attachment links for attachments on a Confluence page from within Jira. 

Environment

Jira Service Management cloud

Solution 

(info) We will use Rest API Calls to Get the list of attachments to the Confluence Page and use the Attachment ID to send an email with a downloadable link:

  • API Calls to Get the Attachment ID: Get Attachments
  • URI Call to Download the Attachment: Download Attachments 
    (warning) Please note the end user must have access to the Confluence page to download the attachment using the link. 

Use the steps below to configure a rule to automatically send an attachment link for direct download:

Step 1: Create an API Key for your admin account
Step 2: Get list of Attachments added to the Page
  • Go to Project Settings > Automation > Create Rule

  • One could either configure an Automated Trigger or have a Manual Trigger; as stated in Jira automation triggers, for the purpose of this example we will useScheduled Trigger.

  • Select "Send Web Request " under "Add an Action" 


    Headers ( Optional )

    Authorization

    Basic  <Base64-ApiKey>

    X-ExperimentalAPIopt-in

    BASE64 encode the string on a Linux/Unix/MacOS:

    echo -n user@example.com:api_token_string | base64

  • HTTP Method: GET 
  • Enable "Delay execution of subsequent rule actions until we've received a response for this web request"
  • Add comments/log action to capture Attachment ID from the Web Response:  {{webResponse.body.results.id}}

Step 3: Send Attachment in Email
  • If there are multiple Attachments, we need to run the API against each Attachment ID
  • Add an Advanced branch component with variable attach referring to the smart value {{webResponse.body.results.id}}

  • Add action Send Email with the following link in the email body

    https://<sitename.atlassian.net>.atlassian.net/wiki/rest/api/content/56360967/child/attachment/{{attach}}/download


To get content/PageID :

Copy it from the URL of the conflunce page: https://<sitename>.atlassian.net/wiki/spaces/AT/pages/<content_ID>/PageName
                                        or
Use the API Call to get the Content ID 

Last modified on Sep 22, 2023

Was this helpful?

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