✅ Downloading file with HttpClient does not work
Hello,
Everywhere it is advisable to use
HttpClient
for downloading larger files.
For some reason it only downloads a little chunk of a larger file, and that's it. How should I even determine what the problem is?
The url is fine, I am able to download the file trough the browser
4 Replies
do you still see this when you use methods like httpClient.GetBytesAsync()? or is it exclusively when working with it as a stream?
perhaps the site could also be sniffing your user-agent and working differently based on that - that's pure speculation, but worth a passing thought
Yes, unfortunately it's the same with GetBytes. Actually, the website specifically hands out an access token and an URL that exposes the file
I guess it's not about the user-agent
also I've exhausted my daily download limit, now I'm trying to download from Dropbox.... But the issue was the same when I tried to download from the original site
my next step in that case would be to see if you can make the request succesfully outside of c#, i.e. in Postman or something similar
as a way to isolate if it's the http request that's not working or the HttpClient specifically
thinking on it, this could also be caused by chunked transfer encoding
i've not been bitten by that before so i don't know if you need to do anything special with httpclient, but worth looking into
Thank you for helping me