During JIRA ServiceNow integration , when attachment is sent from servicenow but not added in JIRA Issue attachments . why it is not added in attachment and what is left to be done so that it can get added
Hi @Prajwal Ashok Nagrale and welcome to the community,
How did you integrate SN and Jira? Are you using a Plugin? If so: which one? How are attachments sent to jira?
Please share some more details regarding your problems. This helps the community to find a solution.
BestStefan
Hi, we have used REST Api to *integrate SN and JIRA .
In order to be able to analyse the problem the community please add some deeper insight and details.
Without knowing how your integration/calls look like, where are they triggered, how is api call sent, etc... the community could just do guesses.
Integration call through business rule of serviceNow
(function executeRule(current, previous /null when async/ ) {
var arr = [];
var gsu = (typeof GlideStringUtil != 'undefined') ? (GlideStringUtil) : (Packages.com.glide.util.StringUtil); //few versions support the first one, other supports second
var gsa = (typeof GlideSysAttachment != 'undefined') ? (new GlideSysAttachment()) : (new Packages.com.glide.ui.SysAttachment());
var gr = new GlideRecord("sys_attachment");
gr.addQuery('table_sys_id', current.table_sys_id);
gr.query();
while (gr.next()) {
var attachmentData = gsa.getBytes(gr);
var attachment = String(Packages.java.lang.String(attachmentData));
var encData = GlideStringUtil.base64Encode(attachmentData);
var obj = {};
obj["content_type"] = gr.getValue('content_type');
obj["file_name"] = JSUtil.escapeText(gr.getValue('file_name'));
obj["size_bytes"] = gr.getValue("size_bytes ");
obj["sys_id"] = gr.getUniqueValue();
obj["Content-Transfer-Encoding"] = "base64" + encData.toString();
arr.push(obj);
}
var finalObj = {};
finalObj["attachment"] = arr;
var sm = new sn_ws.RESTMessageV2('Neste Siili JIRA', 'Add attachment');
var response = sm.execute();
var status = response.getStatusCode();
gs.info("Payload sent jira: " + sm.getRequestBody());
gs.info("Response jira: " + response.getBody());
gs.info("Status jira : " + status);
})(current, previous);
Payload --
{ "attachments": [{ "content_type": "image/png", "file_name": "Screenshot (153).png", "size_bytes ": "137246 ", "sys_id": "f576b5211b091950f7b82fcde54bcbae","Content-Transfer-Encoding": "base64${base64EncodedData}" }] }
Hi @Prajwal Ashok Nagrale
I do not know any engine of SN. I can just reflect the issue from Jira perspective.
So which endpoint of the jira API are you calling? How do you determine the issue key where the attachment should be added?
It looks like you're new here. Sign in or register to get started.