question

Andreasss-5315 avatar image
0 Votes"
Andreasss-5315 asked Andreasss-5315 edited

I return an empy string when doing this HttpWebRequest

Hello!

I am trying to do a HttpWebRequest to the below URL. When I do that, I return an empty string.

However, when I put the URL manually in the chrome browser. There is a large JSON string on this URL.

I wonder why I return an empy string with the below URL?

Thank you!

             try
             {
                 String URL = "https://api.etherscan.io/api?module=account&action=txlist&address=0xea482c608fedbaebb2bee4456d19acb3270f8355&startblock=12226259&endblock=99999999&sort=asc&apikey=1BDWT2SMX7KPV21FXPT932GZPMX4";
    
                 HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
                 myRequest.Timeout = 60000;
                 myRequest.Method = "GET";
                 myRequest.Accept = "application/json";
                 myRequest.ContentType = "application/json; charset=utf-8";
                 WebResponse myResponse = myRequest.GetResponse();
    
                 var response = (System.Net.HttpWebResponse)myRequest.GetResponse();
                 String responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
    
                 MessageBox.Show(responseString);
             }
             catch(Exception ex) { MessageBox.Show(ex.ToString()); }
dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
1 Vote"
Castorix31 answered Andreasss-5315 edited

I just tested and the string is not empy

If you replace the MessageBox by :

 Console.WriteLine(responseString);

it is displayed in the Output window


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You are right. That was strange.

I tried to write it to a file instead and then the string is written.
I wonder why the MessageBox.Show("..") doesn't show the string. Is it because it is to large?

Thank you!

0 Votes 0 ·