Skip to content

Instantly share code, notes, and snippets.

@bryanbarnard
Created June 20, 2016 03:24
Show Gist options
  • Save bryanbarnard/8b80dd64366a902d11275cf42df69229 to your computer and use it in GitHub Desktop.
Save bryanbarnard/8b80dd64366a902d11275cf42df69229 to your computer and use it in GitHub Desktop.
Using getResponseAttachmentSysid()
var tablename = 'incident';
var recordSysId = '3197671513d75200a54fb8b12244b0f6';
var filename = 'new_image.jpeg';
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint('https://demonightlyus.service-now.com/api/now/attachment/2b6644b15f1021001c9b2572f2b47763/file');
request.saveResponseBodyAsAttachment(tablename, recordSysId, filename);
request.setBasicAuth('admin', '{update_with_password');
var response = request.execute();
var httpResponseStatus = response.getStatusCode();
var httpResponseContentType = response.getHeader('Content-Type');
var newAttachmentSysId = response.getResponseAttachmentSysid();
var parsed;
var httpResponseBody;
gs.debug("http response status_code: " + httpResponseStatus);
gs.debug("http response content-type: " + httpResponseContentType);
gs.debug(newAttachmentSysId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment