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.
Navigate to iHub Cloud.
Click Integrations.
Click "New Integration."
Select a Trigger. Choose an event that initiates the automation, such as "Issue Created" or "Issue Updated."
Click Save.
Add a Web Action. Click "Add New Action" and select "Web Action."
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}}/attachmentsSelect POST Method.
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: Create Credentials
Add Header:
X-Atlassian-Token
value:no-check
Set Body Format to Form-Data. In the "Body" section, select "form-data."
Enter the Body Content. Paste the following JSON code, replacing
{{attachments.unsent}}
if you only want to send unsent attachments:
{
"file":"{{attachments.unsent}}"
}
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:
Navigate to the Conditions Tab. Click the "Conditions" tab in your iHub action.
Add a Data Condition. Click "Add" and select "Data Condition."
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.