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.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}"
}]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Just want to know in Which format Jira accepts an Attachment using Rest API ?
Regards,
Prajwal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is an example how an attachment can be added via curl api call:
curl --location --request POST 'https://your-domain.atlassian.net/rest/api/3/issue/TEST-123/attachments' -u 'email@example.com:<api_token>' -H 'X-Atlassian-Token: no-check' --form 'file=@"myfile.txt"'
see detailed documentation here:
Hope this is helpful.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you check whether this payload is correct for jira.
{
"attachment": [{
"content_type": "text/plain",
"file_name": "test.txt",
"size_bytes": "2",
"sys_id": "1326b90a1bc3d51014811023b24bcb5c",
"Content-Transfer-Encoding": "base64dHQ="
}]
}
and the reponse from JIRA is Blank. do you know why the response is blank ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To be honest I´m not a developer. I can handle easy api calls as described in the documentation. So adding attachment via curl (as described above) worked in my system.
What I could find in the community was the following post. The question from Radek on 11.02. might cover your problem:
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.