- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2023 04:26 AM
I am getting the below response body from http get method.
{"id":"718564","ticket_id":"CYDERES-1083083","file_name":"Test attachment for SNOW test.txt","created_at":"2023-11-28T13:19:03.887-0600","mime_type":"text/plain","bytes_data":"b'This is a teste attachment for the SI integration with Service Now.'"}
Now I want to parse these data and create attachments in ServiceNow. How can I do this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2023 07:06 AM
Hi @Kishor O ,
you can easily use JSON.parse(<put_your_body_here>).
//request_body from your Rest call
var msg = JSON.parse(request_body);
var attachment = new GlideSysAttachment();
//set up inputs
var rec = new GlideRecord('incident');
rec.get("<your_id_field>", msg.ticket_id);
var fileName = msg.file_name;
var contentType = msg.mime_type;
var content = msg.bytes_data;
var agr = attachment.write(rec, fileName, contentType, content);
gs.info('The attachment sys_id is: ' + agr);
Greets
Daniel
Please mark reply as Helpful/Correct, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2023 07:06 AM
Hi @Kishor O ,
you can easily use JSON.parse(<put_your_body_here>).
//request_body from your Rest call
var msg = JSON.parse(request_body);
var attachment = new GlideSysAttachment();
//set up inputs
var rec = new GlideRecord('incident');
rec.get("<your_id_field>", msg.ticket_id);
var fileName = msg.file_name;
var contentType = msg.mime_type;
var content = msg.bytes_data;
var agr = attachment.write(rec, fileName, contentType, content);
gs.info('The attachment sys_id is: ' + agr);
Greets
Daniel
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2023 10:23 AM
@Daniel Borkowi1 Thank you.It worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2023 11:06 PM
@Kishor O you're welcome.