Attachments - Multipart data or Body

To send an attachment there is two options, Multipart form data - this is what most systems use to work with attachments. Second option is Body this is where the remote system requires the content of the attachment to be included in the body.

 

For JSM comment see this tutorialSend only public comments from Jira Service Management

Body data

Use this method to send the content of the attachment as base64encoded in the body of the request.

Attachment is accessible via {{attachments}} variable, this is a list of attachments. To grab the first, last or latest use the syntax below:

  • {{attachments.first}}

  • {{attachments.last}} same as latest

  • {{attachments.latest}}

example of sending an attachment in the body

Properties on a attachment:

  • content type String base64encoded, ex {{attachments.last.content}}

  • authorKey type String, ex {{attachments.last.authorKey}}

  • authorObject type ApplicationUser, ex {{attachments.last.authorObject.username}}

  • created type Timestamp, ex {{attachments.last.created}}

  • filename type String, ex {{attachments.last.filename}}

  • filesize type Long, ex {{attachments.last.filesize}}

  • id type Long, ex {{attachments.last.id}}

  • mimetype type String, ex {{attachments.last.mimetype}}

  • zip type Boolean, ex {{attachments.last.zip}}

Multipart data - form data

Usage note!

Use this only in the case were attachment is needed, since the payload is different than regular application/json types.

 

Download sample configuration for attaching a file to a ticket from an incoming rule here and import it.

iHub can send attachments to external endpoints. This is done. by sending Content-Type: multipart/form-data.

Content-Type: multipart/form-data

The body will be included in the payload:

Content-Disposition: form-data; name="file" filename="filename_A.xyz" (content of filename_A.xyz) Content-Disposition: form-data; name="file" filename="filename_B.xyz" (content of filename_B.xyz) Content-Disposition: form-data; name="body" {the_body_section_of_the_config_page any content added in the body will be sent as a variable called body} Content-Disposition: form-data; name="formVar_A" {the_formVar_A_content the name of a form var and the content} Content-Disposition: form-data; name="formVar_B" {the_formVar_B_content the name of a form var and the content}













Do not include attachments - This is the standard way of just sending normal JSON data.



Latest - any added attachment during the issue event will be added. Attachments older than 5seconds after the event occurs will not be added.



All - Include all attachments in the payload multipart data



Incoming - When this integration is part of an incoming rule. Read more on incoming: Incoming REST Calls



Form variable value

The file parameter can be changed by changing the Form variable value. 

This can be needed for some APIs to accept attachments. Like Freshdesk needs the file var to be named attachments[]

Skip sending variables that has an empty value

Will remove parameters with empty values from the payload



Implementation of https://datatracker.ietf.org/doc/html/rfc7578 specification.



Mustache variables can be used in both Form vars as in the body.