
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 03:33 AM
Hello experts,
I have a requirement to insert attachments in incident record from 3rd party tool with REST API. They dont have physical location and they are receiving as base64 data from other tool. So they need to use Snow rest api and attach it to target incident record. I have gone through Attachment API provided by Servicenow. But it did not help as it expects the physical location of the file in both of the below methods.
POST /now/attachment/file
POST /now/attachment/upload
Also, I have tried below URL but not working.
http://www.john-james-andersen.com/blog/service-now/generate-attachments-in-servicenow-via-rest.html
Please let me know if you have implemented this.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 07:31 AM
I have achieved using below.
Created a scripted rest API with the below script and successfully created an attachment.
var StringUtil = new GlideStringUtil();
var value = StringUtil.base64DecodeAsBytes(<base64data>);
var attachment = new GlideSysAttachment();
attachment.write(<tablename>,<record_sys_id>,<filename>,'', value);
Thanks,
Sunil Safare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 05:22 AM
I havn't used Attachment API yet. But, can't you just hold that Base64 data in a staging table(using normal POST) and from there use below script to attach
var StringUtil = new GlideStringUtil();
var value = StringUtil.base64DecodeAsBytes(<base64data>);
var attachment = new Attachment();
attachment.write(<tablename>,<record_sys_id>,<filename>,'', value);
Regards
Air

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 07:31 AM
I have achieved using below.
Created a scripted rest API with the below script and successfully created an attachment.
var StringUtil = new GlideStringUtil();
var value = StringUtil.base64DecodeAsBytes(<base64data>);
var attachment = new GlideSysAttachment();
attachment.write(<tablename>,<record_sys_id>,<filename>,'', value);
Thanks,
Sunil Safare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2019 07:03 AM
Yes, that didn't clicked my mind. Glad to know it helped.
Regards
Air