How to send attachment from servicenow JIRA using rest Message

Suman Kumari
Tera Contributor

Hi,

I am facing an issue with sending attachments from ServiceNow to JIRA,using separate end for attachment.

Able to retrieve the attachment on the JIRA side but in encrypted form. The below decode method is not working for me.

Can anybody please tell me how to retrieve the original data from the attachment?

 

 

 

 var fileContent = (new GlideSysAttachment()).getBytes(attachment);
            var base64EncodedFileContent = GlideStringUtil.base64Encode(fileContent);
            var fileContenDecoded = GlideStringUtil.base64Decode(base64EncodedFileContent);

            // Construct the multipart payload
            var multipartPayload = "--" + boundary + "\r\n" +
                "Content-Disposition: form-data; name=\"file\"; filename=\"" + attachment.getValue('file_name') + "\"\r\n" +
                "Content-Type: " + dynamicContentType + "\r\n\r\n";

            // Append the binary content to the payload
            for (var i = 0; i < fileContent.length; i++) {
                multipartPayload += String.fromCharCode(fileContent[i]);
            }
            //multipartPayload += fileContenDecoded;

            multipartPayload += "\r\n" + "--" + boundary;

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Suman Kumari 

so you are consuming JIRA endpoint and trying to attach the file in JIRA to some record in instance?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur, Yes I am consuming JIRA attachment endpoint & attaching the file in ServiceNow & trying to get the file in JIRA  for the respective issue.

Mathieu Lepoutr
Mega Guru

Hi Suman

 

Please check the decoding technique.

 

In my opinion, please have a look at Exalate to help for this integration between Jira and Snow.

 

It is a decentralized integration solution, where you can granuarly decide which data will be send over.

 

The attachments will be sent over with all the meta data included in it