- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 12:42 AM
We have Servicenow integration with 3rd party tool and getting the response body which contains image information as below
"images" : [ {
"height" : 640,
"url" : "https://i.scdn.co/image/ab67616d0000b273fe74a9fd5050aa4c52017dbc",
"width" : 640
} ],
and we have to attach the image to specific retrieved record. Tried with GlidesysAttachment() but no luck.
Solved! Go to Solution.
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 01:53 AM
Hi Reddy,
I was able to download the jpg file and attach the image to a record using the following script.
var tablename = '<table name>';
var recordSysId = '<record id>';
var filename = '<file name>';
try {
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint('https://i.scdn.co/image/ab67616d0000b273fe74a9fd5050aa4c52017dbc');
request.saveResponseBodyAsAttachment(tablename, recordSysId, filename);
var response = request.execute();
httpResponseStatus = response.getStatusCode();
gs.info(" http response status_code: " + httpResponseStatus);
} catch (e) {
gs.info(e.message());
}
Execution result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 12:55 AM
Hi,
won't work unless they send the base64encoded data or something else
Just with the URL you cannot do much
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 01:53 AM
Hi Reddy,
I was able to download the jpg file and attach the image to a record using the following script.
var tablename = '<table name>';
var recordSysId = '<record id>';
var filename = '<file name>';
try {
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint('https://i.scdn.co/image/ab67616d0000b273fe74a9fd5050aa4c52017dbc');
request.saveResponseBodyAsAttachment(tablename, recordSysId, filename);
var response = request.execute();
httpResponseStatus = response.getStatusCode();
gs.info(" http response status_code: " + httpResponseStatus);
} catch (e) {
gs.info(e.message());
}
Execution result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2023 04:02 AM
How can I use this code in UI page please provide the code for that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 03:08 AM
Thank you