// This is where we'll save the attachment var tablename = 'incident'; var recordSysId = '8d6353eac0a8016400d8a125ca14fc1f'; var filename = 'snlogo.png'; // Let's download the ServiceNow Logo var logoUrl = 'https://instance.service-now.com/images/logos/logo_service-now.png'; var request = new sn_ws.RESTMessageV2(); request.setHttpMethod('get'); request.setEndpoint(logoUrl); // Configure the request to save the response as an attachment request.saveResponseBodyAsAttachment(tablename, recordSysId, filename); // When we execute the request, the attachment will automatically be // saved to the record we specified var response = request.execute(); var httpResponseStatus = response.getStatusCode(); var httpResponseContentType = response.getHeader('Content-Type'); gs.debug("http response status_code: " + httpResponseStatus); gs.debug("http response content-type: " + httpResponseContentType); // Get the sys_id of the newly created attachment var newAttachmentSysId = response.getResponseAttachmentSysid(); // Do something useful with it var grAttach = new GlideRecord('sys_attachment'); if (grAttach.get(newAttachmentSysId)) { // Note: we're using the scoped version of GlideSysAttachment // for this example. var gsa = new GlideSysAttachment() var content = gsa.getContent(grAttach); // Now we have the data...the rest is up to you }