How to download attachment using an url "sys_attachment.do?sys_id"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2017 11:51 AM
Hi,
I want to download attachment using url "sys_attachment.do?sys_id" directly instead of usinf rest API.
I have developed the C# Rest Service and inside this service I am calling the service now url directly to download the attachment.
My C# code is as below,
var client = new WebClient();
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + ":" + password));
client.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
client.DownloadFile(new Uri("https://myinstance.service-now.com/sys_attachment.do?sys_id=1234567890"), "E://new_CIP.txt");
It downloads the file as a html code and not the expected one. I want to download large file in one go, I don't want use REST API.
Could you please help me on the same?
Thanks,
Jitesh Zende
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2017 08:09 PM
Hi jitesh,
Below is a sample script to download attachments into a zip file by specify sys_id. Please have a check.
https://www.servicenowguru.com/scripting/download-attachments-zip-file/
Cheers
Henry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2017 10:44 PM
Hi Jitesh,
You may also find the below threads useful
How to download attachments from a particular Assignment Group
https://snprotips.com/blog/2016/2/25/understanding-and-using-glideattachment
How to retrieve an attachment from service now via SOAP Web Service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 12:15 AM
Thanks Henry and Laxmikanth for your response.
Here the issue is that we need to create processor in Snow which is creating some dependency on SNow. I don't like to create it actually.
Is there any other way to download attachment directly in a one go. I have created the C# service which downloads the attachment but the issue is that when we try to download large file then it get failed. Another thing is that I tried with "sys_attachment_doc" table also and It succeed as well. But the issue is that it takes too much time like when we download 1GB file then it takes almost whole day which is not good.
Thanks,
Jitesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2019 09:44 AM
Hi Jitesh,
I am looking for something similar. Have you got this worked out ?