Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

How to download a file from Sharepoint 2013 using REST and C#

$
0
0

I am able to download a file from my SharePoint 2013 server using the following URL and the browser.  The URL is ..files('<filename>')/$value

Now, I'm trying to download that document using C# and REST.  So far I have something like this:

HttpWebRequest request = null;
HttpWebResponse response = null;

string commandString = string.Format("<SITEURL/FOLDER>/files('{0}')/$value", fileName);
Uri uri = new Uri(siteURL + commandString);

//Set up the HTTP Request
request = (HttpWebRequest)WebRequest.Create(uri);
request.Credentials = CredentialCache.DefaultCredentials;
request.Accept = "application/atom+xml";
request.Method = WebRequestMethods.Http.Get;

response = (HttpWebResponse)request.GetResponse();

Now what?? How do I get the file back?  The response stream is empty?!  Any code sample in C# would be appreciated!

Thanks

 


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>