Inserting Attachments in ServiceNow from JIRA without MID-Server using REST

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 04:43 AM
We were successfully able to insert attachments in ServiceNow from JIRA and hence below code can be used for other third party tools.
var targetInstanceURL = "https://jira.******.com/secure/attachment/"+attachment ID+"/";
var targetUserID = "..";
var targetUserPassword = "...";
var sa = new GlideSysAttachment();
var StringUtil = GlideStringUtil();
var answer = "";
var attachmentMsg = {};
sendAttachments();
function sendAttachments() {
var answer = [0, 0]; //successful attachments, failed attachments
//gs.log('Found a attachment##');
var attachmentMessage = new sn_ws.RESTMessageV2();
attachmentMessage.setHttpMethod("get");
attachmentMessage.setBasicAuth(targetUserID, targetUserPassword);
attachmentMessage.setEndpoint(targetInstanceURL);
attachmentMessage.saveResponseBodyAsAttachment("incident", current.sys_id, fileName); // Attachment API documentation for this function
var response = attachmentMessage.execute();
// var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus.toString() == "201") {
answer[0] += 1;
} else {
answer[1] += 1;
}
return answer;
}
I am still searching for ways to insert files in JIRA from SN without MID-Server.
Do let me know in case of any questions !!!!
Thanks
Rohit
- Labels:
-
Integrations
-
Scripting and Coding
- 9,450 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 09:09 PM
Hi Pooja
i did not use this script and came up custom script includes.
thanks
Anupam