The CreatorCon Call for Content is officially open! Get started here.

How can I download a file from an URL and attach it to serivcenow

lior grinberg2
Tera Expert

Hi,

I have a requirement that a user will enter a URL which is a link to a file from the web.

Then service now will download it and attach it to the record (without using a mid server).

I can do a rest call to the URL but if it's a big file 10mb I cannot convert it to an attachment.

Any ideas?

Thanks,

Lior Grinberg 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

without using mid server I doubt it can be achievable if it is to get the file/data from external system

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

josh_nerius
ServiceNow Employee
ServiceNow Employee

Hi Lior, 

You have a couple of options - neither of these require a MID server as long as the location is reachable from your ServiceNow instance directly. 

1. RESTMessageV2 has a saveResponseBodyAsAttachment() method. You must provide a reference to the record you want to attach the saved file to. 

2. The REST step in IntegrationHub has an option to save a response as an attachment. 

find_real_file.png

Do you have options as well for downloading directly the file without extension from the URL this for example - https://.service-now.com/sys_atf_test_result_step.do?CSV I have added the basic authentication (setBasicAuth('xxxx', 'xxxx');) but it only downloads when there is a file extension in the URL