I have a url that requires authentication to access the link. I am trying to download the data to a stream as follows:
var url = representations.Entries.FirstOrDefault().Info.Url.ToString();
try{
using (var httpClient = _httpClientFactory.CreateClient())
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", await token.FetchTokenAsync());
using (var memoryStream = new MemoryStream())
{
var stream = await httpClient.GetStreamAsync(url);
(stream).CopyTo(memoryStream);
memoryStream.Position = 0;
byte[] buffer = new byte[memoryStream.Length];
await memoryStream.ReadAsync(buffer, 0, (int)memoryStream.Length);
return Convert.ToBase64String(buffer);
}
}
} catch (Exception ex)
{
return "";
}
At the line where I load the stream from httpClient it states the following for various aspects of the stream:
Specified method is not supported.