Send attachment to another Jira cloud

Automating Attachment Transfer Between Jira Issues with iHub Cloud

This tutorial guides you through the process of automatically sending attachments from one Jira issue to another using iHub Cloud.

  1. Navigate to iHub Cloud.

  2. Click Integrations.

  3. Click "New Integration."

  4. Select a Trigger. Choose an event that initiates the automation, such as "Issue Created" or "Issue Updated."

  5. Click Save.

  6. Add a Web Action. Click "Add New Action" and select "Web Action."

  7. Enter the Target URL. Use the following format, {{issue.key}} will be replaced for the target issue's key: https://THE_ATLASSIAN_SITE.atlassian.net/rest/api/3/issue/{{issue.key}}/attachments

  8. Select POST Method.

  9. Configure Credentials (if needed). If you haven't already added credentials for the target Jira site, enter them here. You can find instructions for creating credentials in the iHub documentation: https://rixter.atlassian.net/wiki/spaces/RIFJ/pages/1309540370

  10. Add Header: X-Atlassian-Token value: no-check

  11. Set Body Format to Form-Data. In the "Body" section, select "form-data."

  12. Enter the Body Content. Paste the following JSON code, replacing {{attachments.unsent}} if you only want to send unsent attachments:

{ "file":"{{attachments.unsent}}" }
  1. Click Save.

 

Preventing Unnecessary Attachment Calls (Optional):

iHub Cloud allows you to add a condition to prevent unnecessary calls if there are no attachments to send. This helps optimize performance and avoids redundant actions.

Steps:

  1. Navigate to the Conditions Tab. Click the "Conditions" tab in your iHub action.

  2. Add a Data Condition. Click "Add" and select "Data Condition."

  3. Define the Condition. Fill in the following details:

    • JSON Path: Enter $.attachments.unsent.length

    • Operand: Select "Greater than"

    • Value: 0

Explanation:

This condition checks the length of the $.attachments.unsent variable. This variable represents the number of unsent attachments associated with the source Jira issue.

  • If the length is greater than 0 (meaning there are unsent attachments), the web action to send attachments will proceed as planned.

  • If the length is 0 (meaning there are no unsent attachments), the web action will not be triggered, preventing an unnecessary API call.

By implementing this condition, you ensure that iHub Cloud only sends attachments when there are actually new files to transfer, improving efficiency and potentially reducing costs associated with API usage.

https://rixter.atlassian.net/wiki/spaces/RIFJ/pages/1529905160

https://rixter.atlassian.net/wiki/spaces/RIFJ/pages/1529217130