How can ServiceNow get an image from a URL and store it in the sys_attachment table

Rich_Art
Tera Contributor

Hello all,

 

How can I get ServiceNow to get an image from the internet and store it in the sys_attachment table?

1 ACCEPTED SOLUTION

rahulpandey
Kilo Sage
Hi, You can simply fire a rest API (get) call to image url and using saveResponseBodyAsAttachment(String tableName, String recordSysId, String fileName) you can attach to any record.

View solution in original post

3 REPLIES 3

rahulpandey
Kilo Sage
Hi, You can simply fire a rest API (get) call to image url and using saveResponseBodyAsAttachment(String tableName, String recordSysId, String fileName) you can attach to any record.

Rich_Art
Tera Contributor

Thank you. Your reply helped me to find this example, which I eventually used:
https://gist.github.com/jnerius/d2f28b845a64fa7e1d296c79f877a8c2

Rich_Art
Tera Contributor

I also discovered that it can be done by the flow designer:

REST action --> Save as Attachment in the response handler