I'm connecting to an on-prem 2016 SharePoint system.
I'm trying to use REST to download a file from a doc library. I'm able to create the REST call, however the data I'm being returned looks jumbled...
The call:
using (var client = new WebClient())
{
client.Headers.Add(HttpRequestHeader.ContentType, "application/json;odata=verbose");
client.Headers.Add(HttpRequestHeader.Accept, "application/json;odata=verbose");
client.Headers.Add(HttpRequestHeader.ContentEncoding, "UTF-8");
client.Headers.Add(HttpRequestHeader.Cookie, FedAuthToken);
var endpointUri = new Uri("https://test.mycorp.com/sites/RESTPOC/_api/web/getfilebyserverrelativeurl('/sites/RESTPOC/Shared%20Documents/banner-05.jpg')/OpenBinaryStream");
var result = client.DownloadString(endpointUri);
}
The output of 'Result' looks like:
"ÿØÿá\0\u0018Exif\0\0II*\0\b\0\0\0\0\...goes on quite a while...
Any advice on how I should handle this, and the best way to stream this into an actual file?
Thanks