Why can't I access the Yobit API using webclient

The code used.

URL provided

https://yobit.net/api/3/info

It works in IE. He worked with a web client. Now it does not work in the web client. And I wonder what the problem is

Suddenly he stops working. Therefore i check

    Try
        Dim wc = New WebClient
        wc.Headers.Add("Accept", "text/html, application/xhtml+xml, image/jxr, */*")
        wc.Headers.Add("Accept-Encoding", "gzip, deflate")
        wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
        wc.Headers.Add("Accept-Language", "en-US,en;q=0.5")
        wc.DownloadString(URL)
    Catch ex As Exception

    End Try

I also tried the simple version. Does not work

    Try
        Dim wc = New WebClient
        wc.DownloadString(URL)
    Catch ex As Exception

    End Try

In both cases, yobit throw 503 exception is thrown

I am using a script and trying to use internetexplorer for direct access

It works great

GET https://yobit.net/api/3/info HTTP/1.1
Accept: text/html, application/xhtml+xml, image/jxr, */*
Accept-Language: en-US,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: yobit.net
Connection: Keep-Alive
Cookie: __cfduid=de63c60d603f271520b9ee58dfdd257061517932785; cf_clearance=7e58588df28b267842f753567dcdc475d29679a6-1517932789-86400; locale=en

If I use webclient, this is the header

GET https://yobit.net/api/3/info HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Accept: text/html, application/xhtml+xml, image/jxr, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: yobit.net
Connection: Keep-Alive

Almost the same.

Let me try a different URL

Say http://google.com

GET http://www.google.com/ HTTP/1.1
Accept: text/html, application/xhtml+xml, image/jxr, */*
Accept-Language: en-US,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: www.google.com
Connection: Keep-Alive
Cookie: NID=121=GUd4VKHT_gcwUx-hK39mphuCg93Q_W2fL_yCc-JO3AJkgh74EGajif0537eraLK8ns2EdEQPexOOeBxSlOxVrj8t_AVn21FRme2hAxuLXz4F8aCZExIzME4jaYMBuUp_lnak5Q; OGPC=19004116-3:; 1P_JAR=2018-1-9-7

If I use webclient

GET http://google.com/ HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Accept: text/html, application/xhtml+xml, image/jxr, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: google.com
Connection: Keep-Alive

Both work.

+4
source share
1 answer

There may be various problems.

Framework

, , - . ,

WebClient , gzip, . , gzip , , gzip. ,

wc.Headers.Add("Accept-Encoding", "gzip, deflate")

wc.Headers.Add("Accept-Encoding", "deflate")

, , , ,

class Program
{
    class MyWebClient : WebClient
    {
        protected override WebRequest GetWebRequest(Uri address)
        {
            var request = base.GetWebRequest(address) as HttpWebRequest;
            request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
            return request;
        }
    }
    public static void Main(string[] args)
    {
        var URL = "https://yobit.net/api/3/info";
        var wc = new WebClient();
        wc.Headers.Add("Accept", "text/html, application/xhtml+xml, image/jxr, */*");
        wc.Headers.Add("Accept-Encoding", "gzip, deflate");
        wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
        wc.Headers.Add("Accept-Language", "en-US,en;q=0.5");
        Console.WriteLine(wc.DownloadString(URL));
        // TODO: Implement Functionality Here

        Console.Write("Press any key to continue . . . ");
        Console.ReadKey(true);
    }
}

C#, VB.NET,

Working

+2

Source: https://habr.com/ru/post/1693312/


All Articles