0

I'm pretty new to web, now I'm trying to make a test task, a part of task is to download some strings from company site using their API; request by this page https://apitester.com/ works correctly, but when I'm trying to make request in C# code (using WebClient or HttpWebRequest), I get an exception: (308) Permanent Redirect;

WebClient client = new WebClient();
client.Headers.Add("[api key header]", "[api key]");
return client.DownloadString("http://[site].com/api/textstrings/2");

What causes this problem and how can it be solved?

  • [What's difference between HTTP 301 and 308 status codes?](https://stackoverflow.com/q/42136829/7444103). You should follow the redirection (it should be reference in the `Location` header) and update the URI of the request (permanently). – Jimi Mar 07 '19 at 08:47
  • Thank you! It turned out just a redirection to the same URL by HTTPS.. – Sergey Melnikov Mar 07 '19 at 10:24

0 Answers0